<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: menu   menu.js  (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
</head>

<body id="yahoo-com">
<div id="doc3" class="yui-t2">

	<div id="hd">
        <h1>Yahoo! UI Library</h1>
        <h3>Menu&nbsp; <span class="subtitle">2.2.2</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_menu.html">menu</a>
                
                 &gt; menu.js (source view) 
            </p>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">

                    <div id="srcout">
<div class="highlight" ><pre><span class="c">/**</span>
<span class="c">* The Menu class creates a container that holds a vertical list representing </span>
<span class="c">* a set of options or commands.  Menu is the base class for all </span>
<span class="c">* menu containers. </span>
<span class="c">* @param {String} p_oElement String specifying the id attribute of the </span>
<span class="c">* &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element of the menu.</span>
<span class="c">* @param {String} p_oElement String specifying the id attribute of the </span>
<span class="c">* &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; element to be used as the data source </span>
<span class="c">* for the menu.</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">* level-one-html.html#ID-22445964&quot;&gt;HTMLDivElement&lt;/a&gt;} p_oElement Object </span>
<span class="c">* specifying the &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element of the menu.</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">* level-one-html.html#ID-94282980&quot;&gt;HTMLSelectElement&lt;/a&gt;} p_oElement </span>
<span class="c">* Object specifying the &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; element to be used as </span>
<span class="c">* the data source for the menu.</span>
<span class="c">* @param {Object} p_oConfig Optional. Object literal specifying the </span>
<span class="c">* configuration for the menu. See configuration class documentation for </span>
<span class="c">* more details.</span>
<span class="c">* @namespace YAHOO.widget</span>
<span class="c">* @class Menu</span>
<span class="c">* @constructor</span>
<span class="c">* @extends YAHOO.widget.Overlay</span>
<span class="c">*/</span>
<span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>

<span class="k">var</span> <span class="nx">Dom</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span>
    <span class="nx">Event</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">,</span>
    <span class="nx">CustomEvent</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">,</span>
    <span class="nx">Lang</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">;</span>


<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">,</span> <span class="nx">p_oConfig</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">p_oConfig</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">=</span> <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">parent</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">lazyLoad</span> <span class="o">=</span> <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">lazyLoad</span> <span class="o">||</span> <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">lazyload</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">itemData</span> <span class="o">=</span> <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">itemData</span> <span class="o">||</span> <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">itemdata</span><span class="o">;</span>

    <span class="o">}</span>


    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span>
        <span class="k">this</span><span class="o">,</span> 
        <span class="nx">p_oElement</span><span class="o">,</span> 
        <span class="nx">p_oConfig</span>
    <span class="o">);</span>

<span class="o">};</span>


<span class="c">/**</span>
<span class="c">* Constant representing the name of the Menu&#39;s events</span>
<span class="c">* @property YAHOO.widget.Menu._EVENT_TYPES</span>
<span class="c">* @private</span>
<span class="c">* @final</span>
<span class="c">* @type Object</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">_EVENT_TYPES</span> <span class="o">=</span> <span class="o">{</span>

    <span class="s2">&quot;MOUSE_OVER&quot;</span><span class="o">:</span> <span class="s2">&quot;mouseover&quot;</span><span class="o">,</span>
    <span class="s2">&quot;MOUSE_OUT&quot;</span><span class="o">:</span> <span class="s2">&quot;mouseout&quot;</span><span class="o">,</span>
    <span class="s2">&quot;MOUSE_DOWN&quot;</span><span class="o">:</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span>
    <span class="s2">&quot;MOUSE_UP&quot;</span><span class="o">:</span> <span class="s2">&quot;mouseup&quot;</span><span class="o">,</span>
    <span class="s2">&quot;CLICK&quot;</span><span class="o">:</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span>
    <span class="s2">&quot;KEY_PRESS&quot;</span><span class="o">:</span> <span class="s2">&quot;keypress&quot;</span><span class="o">,</span>
    <span class="s2">&quot;KEY_DOWN&quot;</span><span class="o">:</span> <span class="s2">&quot;keydown&quot;</span><span class="o">,</span>
    <span class="s2">&quot;KEY_UP&quot;</span><span class="o">:</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span>
    <span class="s2">&quot;FOCUS&quot;</span><span class="o">:</span> <span class="s2">&quot;focus&quot;</span><span class="o">,</span>
    <span class="s2">&quot;BLUR&quot;</span><span class="o">:</span> <span class="s2">&quot;blur&quot;</span><span class="o">,</span>
    <span class="s2">&quot;ITEM_ADDED&quot;</span><span class="o">:</span> <span class="s2">&quot;itemAdded&quot;</span><span class="o">,</span>
    <span class="s2">&quot;ITEM_REMOVED&quot;</span><span class="o">:</span> <span class="s2">&quot;itemRemoved&quot;</span>

<span class="o">};</span>



<span class="c">/**</span>
<span class="c">* @method _checkPosition</span>
<span class="c">* @description Checks to make sure that the value of the &quot;position&quot; property </span>
<span class="c">* is one of the supported strings. Returns true if the position is supported.</span>
<span class="c">* @private</span>
<span class="c">* @param {Object} p_sPosition String specifying the position of the menu.</span>
<span class="c">* @return {Boolean}</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">_checkPosition</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sPosition</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_sPosition</span> <span class="o">==</span> <span class="s2">&quot;string&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">sPosition</span> <span class="o">=</span> <span class="nx">p_sPosition</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

        <span class="k">return</span> <span class="o">(</span><span class="s2">&quot;dynamic,static&quot;</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">sPosition</span><span class="o">)</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">};</span>



<span class="c">/**</span>
<span class="c">* Constant representing the Menu&#39;s configuration properties</span>
<span class="c">* @property YAHOO.widget.Menu._DEFAULT_CONFIG</span>
<span class="c">* @private</span>
<span class="c">* @final</span>
<span class="c">* @type Object</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">_DEFAULT_CONFIG</span> <span class="o">=</span> <span class="o">{</span>

    <span class="s2">&quot;VISIBLE&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;visible&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span>
    <span class="o">},</span> 

    <span class="s2">&quot;CONSTRAIN_TO_VIEWPORT&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;constraintoviewport&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">,</span> 
        <span class="nx">supercedes</span><span class="o">:</span> <span class="o">[</span><span class="s2">&quot;iframe&quot;</span><span class="o">,</span><span class="s2">&quot;x&quot;</span><span class="o">,</span><span class="s2">&quot;y&quot;</span><span class="o">,</span><span class="s2">&quot;xy&quot;</span><span class="o">]</span>
    <span class="o">},</span> 

    <span class="s2">&quot;POSITION&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;position&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="s2">&quot;dynamic&quot;</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">_checkPosition</span><span class="o">,</span> 
        <span class="nx">supercedes</span><span class="o">:</span> <span class="o">[</span><span class="s2">&quot;visible&quot;</span><span class="o">]</span> 
    <span class="o">},</span> 

    <span class="s2">&quot;SUBMENU_ALIGNMENT&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;submenualignment&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="o">[</span><span class="s2">&quot;tl&quot;</span><span class="o">,</span><span class="s2">&quot;tr&quot;</span><span class="o">]</span>
    <span class="o">},</span>

    <span class="s2">&quot;AUTO_SUBMENU_DISPLAY&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;autosubmenudisplay&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span> 
    <span class="o">},</span> 

    <span class="s2">&quot;SHOW_DELAY&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;showdelay&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="m">250</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span> 
    <span class="o">},</span> 

    <span class="s2">&quot;HIDE_DELAY&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;hidedelay&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">,</span> 
        <span class="nx">suppressEvent</span><span class="o">:</span> <span class="kc">true</span>
    <span class="o">},</span> 

    <span class="s2">&quot;SUBMENU_HIDE_DELAY&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;submenuhidedelay&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="m">250</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span>
    <span class="o">},</span> 

    <span class="s2">&quot;CLICK_TO_HIDE&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;clicktohide&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span>
    <span class="o">},</span>

    <span class="s2">&quot;CONTAINER&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;container&quot;</span>
    <span class="o">},</span> 

    <span class="s2">&quot;MAX_HEIGHT&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;maxheight&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span>
    <span class="o">},</span> 

    <span class="s2">&quot;CLASS_NAME&quot;</span><span class="o">:</span> <span class="o">{</span> 
        <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;classname&quot;</span><span class="o">,</span> 
        <span class="nx">value</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span> 
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span>
    <span class="o">}</span>

<span class="o">};</span>


<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Overlay</span><span class="o">,</span> <span class="o">{</span>


<span class="c">// Constants</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @property CSS_CLASS_NAME</span>
<span class="c">* @description String representing the CSS class(es) to be applied to the </span>
<span class="c">* menu&#39;s &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element.</span>
<span class="c">* @default &quot;yuimenu&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">CSS_CLASS_NAME</span><span class="o">:</span> <span class="s2">&quot;yuimenu&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property ITEM_TYPE</span>
<span class="c">* @description Object representing the type of menu item to instantiate and </span>
<span class="c">* add when parsing the child nodes (either &lt;code&gt;&amp;#60;li&amp;#62;&lt;/code&gt; element, </span>
<span class="c">* &lt;code&gt;&amp;#60;optgroup&amp;#62;&lt;/code&gt; element or &lt;code&gt;&amp;#60;option&amp;#62;&lt;/code&gt;) </span>
<span class="c">* of the menu&#39;s source HTML element.</span>
<span class="c">* @default YAHOO.widget.MenuItem</span>
<span class="c">* @final</span>
<span class="c">* @type YAHOO.widget.MenuItem</span>
<span class="c">*/</span>
<span class="nx">ITEM_TYPE</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property GROUP_TITLE_TAG_NAME</span>
<span class="c">* @description String representing the tagname of the HTML element used to </span>
<span class="c">* title the menu&#39;s item groups.</span>
<span class="c">* @default H6</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">GROUP_TITLE_TAG_NAME</span><span class="o">:</span> <span class="s2">&quot;h6&quot;</span><span class="o">,</span>



<span class="c">// Private properties</span>
<span class="c"></span>

<span class="c">/** </span>
<span class="c">* @property _nHideDelayId</span>
<span class="c">* @description Number representing the time-out setting used to cancel the </span>
<span class="c">* hiding of a menu.</span>
<span class="c">* @default null</span>
<span class="c">* @private</span>
<span class="c">* @type Number</span>
<span class="c">*/</span>
<span class="nx">_nHideDelayId</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _nShowDelayId</span>
<span class="c">* @description Number representing the time-out setting used to cancel the </span>
<span class="c">* showing of a menu.</span>
<span class="c">* @default null</span>
<span class="c">* @private</span>
<span class="c">* @type Number</span>
<span class="c">*/</span>
<span class="nx">_nShowDelayId</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _nSubmenuHideDelayId</span>
<span class="c">* @description Number representing the time-out setting used to cancel the </span>
<span class="c">* hiding of a submenu.</span>
<span class="c">* @default null</span>
<span class="c">* @private</span>
<span class="c">* @type Number</span>
<span class="c">*/</span>
<span class="nx">_nSubmenuHideDelayId</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _nBodyScrollId</span>
<span class="c">* @description Number representing the time-out setting used to cancel the </span>
<span class="c">* scrolling of the menu&#39;s body element.</span>
<span class="c">* @default null</span>
<span class="c">* @private</span>
<span class="c">* @type Number</span>
<span class="c">*/</span>
<span class="nx">_nBodyScrollId</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _bHideDelayEventHandlersAssigned</span>
<span class="c">* @description Boolean indicating if the &quot;mouseover&quot; and &quot;mouseout&quot; event </span>
<span class="c">* handlers used for hiding the menu via a call to &quot;window.setTimeout&quot; have </span>
<span class="c">* already been assigned.</span>
<span class="c">* @default false</span>
<span class="c">* @private</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">_bHideDelayEventHandlersAssigned</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _bHandledMouseOverEvent</span>
<span class="c">* @description Boolean indicating the current state of the menu&#39;s </span>
<span class="c">* &quot;mouseover&quot; event.</span>
<span class="c">* @default false</span>
<span class="c">* @private</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">_bHandledMouseOverEvent</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _bHandledMouseOutEvent</span>
<span class="c">* @description Boolean indicating the current state of the menu&#39;s</span>
<span class="c">* &quot;mouseout&quot; event.</span>
<span class="c">* @default false</span>
<span class="c">* @private</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">_bHandledMouseOutEvent</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _aGroupTitleElements</span>
<span class="c">* @description Array of HTML element used to title groups of menu items.</span>
<span class="c">* @default []</span>
<span class="c">* @private</span>
<span class="c">* @type Array</span>
<span class="c">*/</span>
<span class="nx">_aGroupTitleElements</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _aItemGroups</span>
<span class="c">* @description Multi-dimensional Array representing the menu items as they</span>
<span class="c">* are grouped in the menu.</span>
<span class="c">* @default []</span>
<span class="c">* @private</span>
<span class="c">* @type Array</span>
<span class="c">*/</span>
<span class="nx">_aItemGroups</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _aListElements</span>
<span class="c">* @description Array of &lt;code&gt;&amp;#60;ul&amp;#62;&lt;/code&gt; elements, each of which is </span>
<span class="c">* the parent node for each item&#39;s &lt;code&gt;&amp;#60;li&amp;#62;&lt;/code&gt; element.</span>
<span class="c">* @default []</span>
<span class="c">* @private</span>
<span class="c">* @type Array</span>
<span class="c">*/</span>
<span class="nx">_aListElements</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _nCurrentMouseX</span>
<span class="c">* @description The current x coordinate of the mouse inside the area of </span>
<span class="c">* the menu.</span>
<span class="c">* @default 0</span>
<span class="c">* @private</span>
<span class="c">* @type Number</span>
<span class="c">*/</span>
<span class="nx">_nCurrentMouseX</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _nMaxHeight</span>
<span class="c">* @description The original value of the &quot;maxheight&quot; configuration property </span>
<span class="c">* as set by the user.</span>
<span class="c">* @default -1</span>
<span class="c">* @private</span>
<span class="c">* @type Number</span>
<span class="c">*/</span>
<span class="nx">_nMaxHeight</span><span class="o">:</span> <span class="o">-</span><span class="m">1</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _bStopMouseEventHandlers</span>
<span class="c">* @description Stops &quot;mouseover,&quot; &quot;mouseout,&quot; and &quot;mousemove&quot; event handlers </span>
<span class="c">* from executing.</span>
<span class="c">* @default false</span>
<span class="c">* @private</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">_bStopMouseEventHandlers</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property _sClassName</span>
<span class="c">* @description The current value of the &quot;classname&quot; configuration attribute.</span>
<span class="c">* @default null</span>
<span class="c">* @private</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">_sClassName</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>



<span class="c">// Public properties</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @property lazyLoad</span>
<span class="c">* @description Boolean indicating if the menu&#39;s &quot;lazy load&quot; feature is </span>
<span class="c">* enabled.  If set to &quot;true,&quot; initialization and rendering of the menu&#39;s </span>
<span class="c">* items will be deferred until the first time it is made visible.  This </span>
<span class="c">* property should be set via the constructor using the configuration </span>
<span class="c">* object literal.</span>
<span class="c">* @default false</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">lazyLoad</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property itemData</span>
<span class="c">* @description Array of items to be added to the menu.  The array can contain </span>
<span class="c">* strings representing the text for each item to be created, object literals </span>
<span class="c">* representing the menu item configuration properties, or MenuItem instances.  </span>
<span class="c">* This property should be set via the constructor using the configuration </span>
<span class="c">* object literal.</span>
<span class="c">* @default null</span>
<span class="c">* @type Array</span>
<span class="c">*/</span>
<span class="nx">itemData</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property activeItem</span>
<span class="c">* @description Object reference to the item in the menu that has is selected.</span>
<span class="c">* @default null</span>
<span class="c">* @type YAHOO.widget.MenuItem</span>
<span class="c">*/</span>
<span class="nx">activeItem</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property parent</span>
<span class="c">* @description Object reference to the menu&#39;s parent menu or menu item.  </span>
<span class="c">* This property can be set via the constructor using the configuration </span>
<span class="c">* object literal.</span>
<span class="c">* @default null</span>
<span class="c">* @type YAHOO.widget.MenuItem</span>
<span class="c">*/</span>
<span class="nx">parent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property srcElement</span>
<span class="c">* @description Object reference to the HTML element (either </span>
<span class="c">* &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt;) used to </span>
<span class="c">* create the menu.</span>
<span class="c">* @default null</span>
<span class="c">* @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">* level-one-html.html#ID-94282980&quot;&gt;HTMLSelectElement&lt;/a&gt;|&lt;a </span>
<span class="c">* href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.</span>
<span class="c">* html#ID-22445964&quot;&gt;HTMLDivElement&lt;/a&gt;</span>
<span class="c">*/</span>
<span class="nx">srcElement</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>



<span class="c">// Events</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @event mouseOverEvent</span>
<span class="c">* @description Fires when the mouse has entered the menu.  Passes back </span>
<span class="c">* the DOM Event object as an argument.</span>
<span class="c">*/</span>
<span class="nx">mouseOverEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event mouseOutEvent</span>
<span class="c">* @description Fires when the mouse has left the menu.  Passes back the DOM </span>
<span class="c">* Event object as an argument.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">mouseOutEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event mouseDownEvent</span>
<span class="c">* @description Fires when the user mouses down on the menu.  Passes back the </span>
<span class="c">* DOM Event object as an argument.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">mouseDownEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event mouseUpEvent</span>
<span class="c">* @description Fires when the user releases a mouse button while the mouse is </span>
<span class="c">* over the menu.  Passes back the DOM Event object as an argument.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">mouseUpEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event clickEvent</span>
<span class="c">* @description Fires when the user clicks the on the menu.  Passes back the </span>
<span class="c">* DOM Event object as an argument.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">clickEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event keyPressEvent</span>
<span class="c">* @description Fires when the user presses an alphanumeric key when one of the</span>
<span class="c">* menu&#39;s items has focus.  Passes back the DOM Event object as an argument.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">keyPressEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event keyDownEvent</span>
<span class="c">* @description Fires when the user presses a key when one of the menu&#39;s items </span>
<span class="c">* has focus.  Passes back the DOM Event object as an argument.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">keyDownEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event keyUpEvent</span>
<span class="c">* @description Fires when the user releases a key when one of the menu&#39;s items </span>
<span class="c">* has focus.  Passes back the DOM Event object as an argument.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">keyUpEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event itemAddedEvent</span>
<span class="c">* @description Fires when an item is added to the menu.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">itemAddedEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @event itemRemovedEvent</span>
<span class="c">* @description Fires when an item is removed to the menu.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>
<span class="nx">itemRemovedEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @method init</span>
<span class="c">* @description The Menu class&#39;s initialization method. This method is </span>
<span class="c">* automatically called by the constructor, and sets up all DOM references </span>
<span class="c">* for pre-existing markup, and creates required markup if it is not </span>
<span class="c">* already present.</span>
<span class="c">* @param {String} p_oElement String specifying the id attribute of the </span>
<span class="c">* &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element of the menu.</span>
<span class="c">* @param {String} p_oElement String specifying the id attribute of the </span>
<span class="c">* &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; element to be used as the data source </span>
<span class="c">* for the menu.</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">* level-one-html.html#ID-22445964&quot;&gt;HTMLDivElement&lt;/a&gt;} p_oElement Object </span>
<span class="c">* specifying the &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element of the menu.</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">* level-one-html.html#ID-94282980&quot;&gt;HTMLSelectElement&lt;/a&gt;} p_oElement </span>
<span class="c">* Object specifying the &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; element to be used as </span>
<span class="c">* the data source for the menu.</span>
<span class="c">* @param {Object} p_oConfig Optional. Object literal specifying the </span>
<span class="c">* configuration for the menu. See configuration class documentation for </span>
<span class="c">* more details.</span>
<span class="c">*/</span>
<span class="nx">init</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">,</span> <span class="nx">p_oConfig</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span> <span class="o">=</span> <span class="o">[];</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span> <span class="o">=</span> <span class="o">[];</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span> <span class="o">=</span> <span class="o">[];</span>

    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">ITEM_TYPE</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">ITEM_TYPE</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuItem</span><span class="o">;</span>

    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">oElement</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_oElement</span> <span class="o">==</span> <span class="s2">&quot;string&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">oElement</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">oElement</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">;</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">switch</span><span class="o">(</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">())</span> <span class="o">{</span>
    
            <span class="nx">case</span> <span class="s2">&quot;DIV&quot;</span><span class="o">:</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">;</span>

                <span class="k">if</span><span class="o">(!</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>

                    <span class="nx">oElement</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">,</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">());</span>

                <span class="o">}</span>


                <span class="c">/* </span>
<span class="c">                    Note: we don&#39;t pass the user config in here yet </span>
<span class="c">                    because we only want it executed once, at the lowest </span>
<span class="c">                    subclass level.</span>
<span class="c">                */</span> 
            
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">init</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oElement</span><span class="o">);</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">beforeInitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">);</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Source element: &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">);</span>
    
            <span class="k">break</span><span class="o">;</span>
    
            <span class="nx">case</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">:</span>
    
                <span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">;</span>

    
                <span class="c">/*</span>
<span class="c">                    The source element is not something that we can use </span>
<span class="c">                    outright, so we need to create a new Overlay</span>
<span class="c"></span>
<span class="c">                    Note: we don&#39;t pass the user config in here yet </span>
<span class="c">                    because we only want it executed once, at the lowest </span>
<span class="c">                    subclass level.</span>
<span class="c">                */</span> 

                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">init</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">());</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">beforeInitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">);</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Source element: &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">);</span>

            <span class="k">break</span><span class="o">;</span>

        <span class="o">}</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="c">/* </span>
<span class="c">            Note: we don&#39;t pass the user config in here yet </span>
<span class="c">            because we only want it executed once, at the lowest </span>
<span class="c">            subclass level.</span>
<span class="c">        */</span> 
    
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">init</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">p_oElement</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">beforeInitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;No source element found.  &quot;</span> <span class="o">+</span>
            <span class="s2">&quot;Created element with id: &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oEl</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">;</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oEl</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span><span class="o">);</span>


        <span class="c">// Subscribe to Custom Events</span>
<span class="c"></span>
        <span class="k">this</span><span class="o">.</span><span class="nx">initEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onInit</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">beforeRenderEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onBeforeRender</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">renderEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onRender</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">beforeShowEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onBeforeShow</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onShow</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">beforeHideEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onBeforeHide</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">hideEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onHide</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">mouseOverEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMouseOver</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">mouseOutEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMouseOut</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">clickEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onClick</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">keyDownEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onKeyDown</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">keyPressEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onKeyPress</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Module</span><span class="o">.</span><span class="nx">textResizeEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_onTextResize</span><span class="o">,</span> 
            <span class="k">this</span><span class="o">,</span> 
            <span class="kc">true</span>
        <span class="o">);</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">p_oConfig</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">applyConfig</span><span class="o">(</span><span class="nx">p_oConfig</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    
        <span class="o">}</span>


        <span class="c">// Register the Menu instance with the MenuManager</span>
<span class="c"></span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuManager</span><span class="o">.</span><span class="nx">addMenu</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
        

        <span class="k">this</span><span class="o">.</span><span class="nx">initEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>



<span class="c">// Private methods</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method _initSubTree</span>
<span class="c">* @description Iterates the childNodes of the source element to find nodes </span>
<span class="c">* used to instantiate menu and menu items.</span>
<span class="c">* @private</span>
<span class="c">*/</span>
<span class="nx">_initSubTree</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oNode</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;DIV&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="c">/*</span>
<span class="c">            Populate the collection of item groups and item</span>
<span class="c">            group titles</span>
<span class="c">        */</span>

        <span class="nx">oNode</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">;</span>

        <span class="k">var</span> <span class="nx">nGroup</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span>
            <span class="nx">sGroupTitleTagName</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">GROUP_TITLE_TAG_NAME</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>

        <span class="k">do</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oNode</span> <span class="o">&amp;&amp;</span> <span class="nx">oNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">switch</span><span class="o">(</span><span class="nx">oNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">())</span> <span class="o">{</span>

                    <span class="nx">case</span> <span class="nx">sGroupTitleTagName</span><span class="o">:</span>
                    
                        <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span><span class="o">[</span><span class="nx">nGroup</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oNode</span><span class="o">;</span>

                    <span class="k">break</span><span class="o">;</span>

                    <span class="nx">case</span> <span class="s2">&quot;UL&quot;</span><span class="o">:</span>

                        <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">nGroup</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oNode</span><span class="o">;</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span><span class="o">[</span><span class="nx">nGroup</span><span class="o">]</span> <span class="o">=</span> <span class="o">[];</span>
                        <span class="nx">nGroup</span><span class="o">++;</span>

                    <span class="k">break</span><span class="o">;</span>

                <span class="o">}</span>
            
            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">while</span><span class="o">((</span><span class="nx">oNode</span> <span class="o">=</span> <span class="nx">oNode</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">));</span>


        <span class="c">/*</span>
<span class="c">            Apply the &quot;first-of-type&quot; class to the first UL to mimic </span>
<span class="c">            the &quot;first-of-type&quot; CSS3 psuedo class.</span>
<span class="c">        */</span>

        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="m">0</span><span class="o">])</span> <span class="o">{</span>

            <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="m">0</span><span class="o">],</span> <span class="s2">&quot;first-of-type&quot;</span><span class="o">);</span>

        <span class="o">}</span>

    <span class="o">}</span>


    <span class="nx">oNode</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Searching DOM for items to initialize.&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">sSrcElementTagName</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>


        <span class="nx">switch</span><span class="o">(</span><span class="nx">sSrcElementTagName</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">case</span> <span class="s2">&quot;DIV&quot;</span><span class="o">:</span>
    
                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Found &quot;</span> <span class="o">+</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> 
                        <span class="s2">&quot; item groups to initialize.&quot;</span><span class="o">);</span>
    
                    <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">.</span><span class="nx">length</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
    
                    <span class="k">do</span> <span class="o">{</span>
    
                        <span class="nx">oNode</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">firstChild</span><span class="o">;</span>
        
                        <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Scanning &quot;</span> <span class="o">+</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">childNodes</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> 
                            <span class="s2">&quot; child nodes for items to initialize.&quot;</span><span class="o">);</span>
    
                        <span class="k">do</span> <span class="o">{</span>
        
                            <span class="k">if</span><span class="o">(</span>
                                <span class="nx">oNode</span> <span class="o">&amp;&amp;</span> 
                                <span class="nx">oNode</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">&amp;&amp;</span> 
                                <span class="nx">oNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;LI&quot;</span>
                            <span class="o">)</span> <span class="o">{</span>
        
                                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Initializing &quot;</span> <span class="o">+</span> 
                                    <span class="nx">oNode</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">+</span> <span class="s2">&quot; node.&quot;</span><span class="o">);</span>

                                <span class="k">this</span><span class="o">.</span><span class="nx">addItem</span><span class="o">(</span>
                                        <span class="k">new</span> <span class="k">this</span><span class="o">.</span><span class="nx">ITEM_TYPE</span><span class="o">(</span>
                                            <span class="nx">oNode</span><span class="o">,</span> 
                                            <span class="o">{</span> <span class="nx">parent</span><span class="o">:</span> <span class="k">this</span> <span class="o">}</span>
                                        <span class="o">),</span> 
                                        <span class="nx">i</span>
                                    <span class="o">);</span>
    
                            <span class="o">}</span>
                
                        <span class="o">}</span>
                        <span class="k">while</span><span class="o">((</span><span class="nx">oNode</span> <span class="o">=</span> <span class="nx">oNode</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">));</span>
                
                    <span class="o">}</span>
                    <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
    
                <span class="o">}</span>
    
            <span class="k">break</span><span class="o">;</span>
    
            <span class="nx">case</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">:</span>
    
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Scanning &quot;</span> <span class="o">+</span>  
                    <span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">childNodes</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> 
                    <span class="s2">&quot; child nodes for items to initialize.&quot;</span><span class="o">);</span>
    
                <span class="nx">oNode</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">;</span>
    
                <span class="k">do</span> <span class="o">{</span>
    
                    <span class="k">if</span><span class="o">(</span><span class="nx">oNode</span> <span class="o">&amp;&amp;</span> <span class="nx">oNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">)</span> <span class="o">{</span>
                    
                        <span class="nx">switch</span><span class="o">(</span><span class="nx">oNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">())</span> <span class="o">{</span>
        
                            <span class="nx">case</span> <span class="s2">&quot;OPTGROUP&quot;</span><span class="o">:</span>
                            <span class="nx">case</span> <span class="s2">&quot;OPTION&quot;</span><span class="o">:</span>
        
                                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Initializing &quot;</span> <span class="o">+</span>  
                                    <span class="nx">oNode</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">+</span> <span class="s2">&quot; node.&quot;</span><span class="o">);</span>
        
                                <span class="k">this</span><span class="o">.</span><span class="nx">addItem</span><span class="o">(</span>
                                        <span class="k">new</span> <span class="k">this</span><span class="o">.</span><span class="nx">ITEM_TYPE</span><span class="o">(</span>
                                                <span class="nx">oNode</span><span class="o">,</span> 
                                                <span class="o">{</span> <span class="nx">parent</span><span class="o">:</span> <span class="k">this</span> <span class="o">}</span>
                                            <span class="o">)</span>
                                        <span class="o">);</span>
        
                            <span class="k">break</span><span class="o">;</span>
        
                        <span class="o">}</span>

                    <span class="o">}</span>
    
                <span class="o">}</span>
                <span class="k">while</span><span class="o">((</span><span class="nx">oNode</span> <span class="o">=</span> <span class="nx">oNode</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">));</span>
    
            <span class="k">break</span><span class="o">;</span>
    
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _getFirstEnabledItem</span>
<span class="c">* @description Returns the first enabled item in the menu.</span>
<span class="c">* @return {YAHOO.widget.MenuItem}</span>
<span class="c">* @private</span>
<span class="c">*/</span>
<span class="nx">_getFirstEnabledItem</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">aItems</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getItems</span><span class="o">(),</span>
        <span class="nx">nItems</span> <span class="o">=</span> <span class="nx">aItems</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
        <span class="nx">oItem</span><span class="o">;</span>
    
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nItems</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>

        <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">aItems</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

        <span class="k">if</span><span class="o">(</span>
            <span class="nx">oItem</span> <span class="o">&amp;&amp;</span> 
            <span class="o">!</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
            <span class="nx">oItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">!=</span> <span class="s2">&quot;none&quot;</span>
        <span class="o">)</span> <span class="o">{</span>

            <span class="k">return</span> <span class="nx">oItem</span><span class="o">;</span>

        <span class="o">}</span>
    
    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _addItemToGroup</span>
<span class="c">* @description Adds a menu item to a group.</span>
<span class="c">* @private</span>
<span class="c">* @param {Number} p_nGroupIndex Number indicating the group to which the </span>
<span class="c">* item belongs.</span>
<span class="c">* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem </span>
<span class="c">* instance to be added to the menu.</span>
<span class="c">* @param {String} p_oItem String specifying the text of the item to be added </span>
<span class="c">* to the menu.</span>
<span class="c">* @param {Object} p_oItem Object literal containing a set of menu item </span>
<span class="c">* configuration properties.</span>
<span class="c">* @param {Number} p_nItemIndex Optional. Number indicating the index at </span>
<span class="c">* which the menu item should be added.</span>
<span class="c">* @return {YAHOO.widget.MenuItem}</span>
<span class="c">*/</span>
<span class="nx">_addItemToGroup</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">,</span> <span class="nx">p_nItemIndex</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oItem</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">p_oItem</span> <span class="k">instanceof</span> <span class="k">this</span><span class="o">.</span><span class="nx">ITEM_TYPE</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_oItem</span><span class="o">;</span>
        <span class="nx">oItem</span><span class="o">.</span><span class="nx">parent</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_oItem</span> <span class="o">==</span> <span class="s2">&quot;string&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">oItem</span> <span class="o">=</span> <span class="k">new</span> <span class="k">this</span><span class="o">.</span><span class="nx">ITEM_TYPE</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">,</span> <span class="o">{</span> <span class="nx">parent</span><span class="o">:</span> <span class="k">this</span> <span class="o">});</span>
    
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_oItem</span> <span class="o">==</span> <span class="s2">&quot;object&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">p_oItem</span><span class="o">.</span><span class="nx">parent</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

        <span class="nx">oItem</span> <span class="o">=</span> <span class="k">new</span> <span class="k">this</span><span class="o">.</span><span class="nx">ITEM_TYPE</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">.</span><span class="nx">text</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">);</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">))</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">;</span>
        
        <span class="o">}</span>


        <span class="k">var</span> <span class="nx">nGroupIndex</span> <span class="o">=</span> <span class="k">typeof</span> <span class="nx">p_nGroupIndex</span> <span class="o">==</span> <span class="s2">&quot;number&quot;</span> <span class="o">?</span> <span class="nx">p_nGroupIndex</span> <span class="o">:</span> <span class="m">0</span><span class="o">,</span>
            <span class="nx">aGroup</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItemGroup</span><span class="o">(</span><span class="nx">nGroupIndex</span><span class="o">),</span>
            <span class="nx">oGroupItem</span><span class="o">;</span>


        <span class="k">if</span><span class="o">(!</span><span class="nx">aGroup</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">aGroup</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_createItemGroup</span><span class="o">(</span><span class="nx">nGroupIndex</span><span class="o">);</span>

        <span class="o">}</span>


        <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_nItemIndex</span> <span class="o">==</span> <span class="s2">&quot;number&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">bAppend</span> <span class="o">=</span> <span class="o">(</span><span class="nx">p_nItemIndex</span> <span class="o">&gt;=</span> <span class="nx">aGroup</span><span class="o">.</span><span class="nx">length</span><span class="o">);</span>            


            <span class="k">if</span><span class="o">(</span><span class="nx">aGroup</span><span class="o">[</span><span class="nx">p_nItemIndex</span><span class="o">])</span> <span class="o">{</span>
    
                <span class="nx">aGroup</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">p_nItemIndex</span><span class="o">,</span> <span class="m">0</span><span class="o">,</span> <span class="nx">oItem</span><span class="o">);</span>
    
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
    
                <span class="nx">aGroup</span><span class="o">[</span><span class="nx">p_nItemIndex</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">;</span>
    
            <span class="o">}</span>


            <span class="nx">oGroupItem</span> <span class="o">=</span> <span class="nx">aGroup</span><span class="o">[</span><span class="nx">p_nItemIndex</span><span class="o">];</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">if</span><span class="o">(</span>
                    <span class="nx">bAppend</span> <span class="o">&amp;&amp;</span> 
                    <span class="o">(</span>
                        <span class="o">!</span><span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span> <span class="o">||</span> 
                        <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">nodeType</span> <span class="o">==</span> <span class="m">11</span>
                    <span class="o">)</span>
                <span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">nGroupIndex</span><span class="o">].</span><span class="nx">appendChild</span><span class="o">(</span>
                        <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span>
                    <span class="o">);</span>
    
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
  
                    <span class="k">function</span> <span class="nx">getNextItemSibling</span><span class="o">(</span><span class="nx">p_aArray</span><span class="o">,</span> <span class="nx">p_nStartIndex</span><span class="o">)</span> <span class="o">{</span>
                
                            <span class="k">return</span> <span class="o">(</span>
                                    <span class="nx">p_aArray</span><span class="o">[</span><span class="nx">p_nStartIndex</span><span class="o">]</span> <span class="o">||</span> 
                                    <span class="nx">getNextItemSibling</span><span class="o">(</span>
                                        <span class="nx">p_aArray</span><span class="o">,</span> 
                                        <span class="o">(</span><span class="nx">p_nStartIndex</span><span class="o">+</span><span class="m">1</span><span class="o">)</span>
                                    <span class="o">)</span>
                                <span class="o">);</span>

                    <span class="o">}</span>
    
    
                    <span class="k">var</span> <span class="nx">oNextItemSibling</span> <span class="o">=</span> 
                            <span class="nx">getNextItemSibling</span><span class="o">(</span><span class="nx">aGroup</span><span class="o">,</span> <span class="o">(</span><span class="nx">p_nItemIndex</span><span class="o">+</span><span class="m">1</span><span class="o">));</span>
    
                    <span class="k">if</span><span class="o">(</span>
                        <span class="nx">oNextItemSibling</span> <span class="o">&amp;&amp;</span> 
                        <span class="o">(</span>
                            <span class="o">!</span><span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span> <span class="o">||</span> 
                            <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">nodeType</span> <span class="o">==</span> <span class="m">11</span>
                        <span class="o">)</span>
                    <span class="o">)</span> <span class="o">{</span>
            
                        <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">nGroupIndex</span><span class="o">].</span><span class="nx">insertBefore</span><span class="o">(</span>
                                <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> 
                                <span class="nx">oNextItemSibling</span><span class="o">.</span><span class="nx">element</span>
                            <span class="o">);</span>
        
                    <span class="o">}</span>
    
                <span class="o">}</span>
    

                <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">parent</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_subscribeToItemEvents</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">);</span>
    
                <span class="k">this</span><span class="o">.</span><span class="nx">_configureSubmenu</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">);</span>
                
                <span class="k">this</span><span class="o">.</span><span class="nx">_updateItemProperties</span><span class="o">(</span><span class="nx">nGroupIndex</span><span class="o">);</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Item inserted.&quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot; Text: &quot;</span> <span class="o">+</span> <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;text&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot; Index: &quot;</span> <span class="o">+</span> <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">index</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot; Group Index: &quot;</span> <span class="o">+</span> <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">groupIndex</span><span class="o">);</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">itemAddedEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">);</span>

                <span class="k">return</span> <span class="nx">oGroupItem</span><span class="o">;</span>
    
            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
    
            <span class="k">var</span> <span class="nx">nItemIndex</span> <span class="o">=</span> <span class="nx">aGroup</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
    
            <span class="nx">aGroup</span><span class="o">[</span><span class="nx">nItemIndex</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">;</span>

            <span class="nx">oGroupItem</span> <span class="o">=</span> <span class="nx">aGroup</span><span class="o">[</span><span class="nx">nItemIndex</span><span class="o">];</span>
    

            <span class="k">if</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">if</span><span class="o">(</span>
                    <span class="o">!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">nGroupIndex</span><span class="o">],</span> 
                        <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span>
                    <span class="o">)</span>
                <span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">nGroupIndex</span><span class="o">].</span><span class="nx">appendChild</span><span class="o">(</span>
                        <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span>
                    <span class="o">);</span>
    
                <span class="o">}</span>
    
                <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;groupindex&quot;</span><span class="o">,</span> <span class="nx">nGroupIndex</span><span class="o">);</span>
                <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;index&quot;</span><span class="o">,</span> <span class="nx">nItemIndex</span><span class="o">);</span>
        
                <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">parent</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
    
                <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">index</span> <span class="o">=</span> <span class="nx">nItemIndex</span><span class="o">;</span>
                <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">groupIndex</span> <span class="o">=</span> <span class="nx">nGroupIndex</span><span class="o">;</span>
        
                <span class="k">this</span><span class="o">.</span><span class="nx">_subscribeToItemEvents</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">);</span>
    
                <span class="k">this</span><span class="o">.</span><span class="nx">_configureSubmenu</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">);</span>
    
                <span class="k">if</span><span class="o">(</span><span class="nx">nItemIndex</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;first-of-type&quot;</span><span class="o">);</span>
        
                <span class="o">}</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Item added.&quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot; Text: &quot;</span> <span class="o">+</span> <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;text&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot; Index: &quot;</span> <span class="o">+</span> <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">index</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot; Group Index: &quot;</span> <span class="o">+</span> <span class="nx">oGroupItem</span><span class="o">.</span><span class="nx">groupIndex</span><span class="o">);</span>
        

                <span class="k">this</span><span class="o">.</span><span class="nx">itemAddedEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">oGroupItem</span><span class="o">);</span>

                <span class="k">return</span> <span class="nx">oGroupItem</span><span class="o">;</span>
    
            <span class="o">}</span>
    
        <span class="o">}</span>

    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _removeItemFromGroupByIndex</span>
<span class="c">* @description Removes a menu item from a group by index.  Returns the menu </span>
<span class="c">* item that was removed.</span>
<span class="c">* @private</span>
<span class="c">* @param {Number} p_nGroupIndex Number indicating the group to which the menu </span>
<span class="c">* item belongs.</span>
<span class="c">* @param {Number} p_nItemIndex Number indicating the index of the menu item </span>
<span class="c">* to be removed.</span>
<span class="c">* @return {YAHOO.widget.MenuItem}</span>
<span class="c">*/</span>
<span class="nx">_removeItemFromGroupByIndex</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">,</span> <span class="nx">p_nItemIndex</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">nGroupIndex</span> <span class="o">=</span> <span class="k">typeof</span> <span class="nx">p_nGroupIndex</span> <span class="o">==</span> <span class="s2">&quot;number&quot;</span> <span class="o">?</span> <span class="nx">p_nGroupIndex</span> <span class="o">:</span> <span class="m">0</span><span class="o">,</span>
        <span class="nx">aGroup</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItemGroup</span><span class="o">(</span><span class="nx">nGroupIndex</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">aGroup</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">aArray</span> <span class="o">=</span> <span class="nx">aGroup</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">p_nItemIndex</span><span class="o">,</span> <span class="m">1</span><span class="o">),</span>
            <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">aArray</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
    
        <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="c">// Update the index and className properties of each member        </span>
<span class="c"></span>            
            <span class="k">this</span><span class="o">.</span><span class="nx">_updateItemProperties</span><span class="o">(</span><span class="nx">nGroupIndex</span><span class="o">);</span>
    
            <span class="k">if</span><span class="o">(</span><span class="nx">aGroup</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="c">// Remove the UL</span>
<span class="c"></span>    
                <span class="k">var</span> <span class="nx">oUL</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">nGroupIndex</span><span class="o">];</span>
    
                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">body</span> <span class="o">&amp;&amp;</span> <span class="nx">oUL</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oUL</span><span class="o">);</span>
    
                <span class="o">}</span>
    
                <span class="c">// Remove the group from the array of items</span>
<span class="c"></span>    
                <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">nGroupIndex</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
    
    
                <span class="c">// Remove the UL from the array of ULs</span>
<span class="c"></span>    
                <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">nGroupIndex</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
    
    
                <span class="c">/*</span>
<span class="c">                     Assign the &quot;first-of-type&quot; class to the new first UL </span>
<span class="c">                     in the collection</span>
<span class="c">                */</span>
    
                <span class="nx">oUL</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
    
                <span class="k">if</span><span class="o">(</span><span class="nx">oUL</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oUL</span><span class="o">,</span> <span class="s2">&quot;first-of-type&quot;</span><span class="o">);</span>
    
                <span class="o">}</span>            
    
            <span class="o">}</span>
    

            <span class="k">this</span><span class="o">.</span><span class="nx">itemRemovedEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">oItem</span><span class="o">);</span>    


            <span class="c">// Return a reference to the item that was removed</span>
<span class="c"></span>        
            <span class="k">return</span> <span class="nx">oItem</span><span class="o">;</span>
    
        <span class="o">}</span>

    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _removeItemFromGroupByValue</span>
<span class="c">* @description Removes a menu item from a group by reference.  Returns the </span>
<span class="c">* menu item that was removed.</span>
<span class="c">* @private</span>
<span class="c">* @param {Number} p_nGroupIndex Number indicating the group to which the</span>
<span class="c">* menu item belongs.</span>
<span class="c">* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem </span>
<span class="c">* instance to be removed.</span>
<span class="c">* @return {YAHOO.widget.MenuItem}</span>
<span class="c">*/</span>    
<span class="nx">_removeItemFromGroupByValue</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">aGroup</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItemGroup</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">aGroup</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">nItems</span> <span class="o">=</span> <span class="nx">aGroup</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
            <span class="nx">nItemIndex</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
    
        <span class="k">if</span><span class="o">(</span><span class="nx">nItems</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">nItems</span><span class="o">-</span><span class="m">1</span><span class="o">;</span>
        
            <span class="k">do</span> <span class="o">{</span>
        
                <span class="k">if</span><span class="o">(</span><span class="nx">aGroup</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">==</span> <span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">nItemIndex</span> <span class="o">=</span> <span class="nx">i</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>    
        
                <span class="o">}</span>
        
            <span class="o">}</span>
            <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
        
            <span class="k">if</span><span class="o">(</span><span class="nx">nItemIndex</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_removeItemFromGroupByIndex</span><span class="o">(</span>
                            <span class="nx">p_nGroupIndex</span><span class="o">,</span> 
                            <span class="nx">nItemIndex</span>
                        <span class="o">);</span>
        
            <span class="o">}</span>
    
        <span class="o">}</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _updateItemProperties</span>
<span class="c">* @description Updates the &quot;index,&quot; &quot;groupindex,&quot; and &quot;className&quot; properties </span>
<span class="c">* of the menu items in the specified group. </span>
<span class="c">* @private</span>
<span class="c">* @param {Number} p_nGroupIndex Number indicating the group of items to update.</span>
<span class="c">*/</span>
<span class="nx">_updateItemProperties</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">aGroup</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItemGroup</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">),</span>
        <span class="nx">nItems</span> <span class="o">=</span> <span class="nx">aGroup</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">nItems</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">nItems</span> <span class="o">-</span> <span class="m">1</span><span class="o">,</span>
            <span class="nx">oItem</span><span class="o">,</span>
            <span class="nx">oLI</span><span class="o">;</span>

        <span class="c">// Update the index and className properties of each member</span>
<span class="c"></span>    
        <span class="k">do</span> <span class="o">{</span>

            <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">aGroup</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="nx">oLI</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">element</span><span class="o">;</span>

                <span class="nx">oItem</span><span class="o">.</span><span class="nx">index</span> <span class="o">=</span> <span class="nx">i</span><span class="o">;</span>
                <span class="nx">oItem</span><span class="o">.</span><span class="nx">groupIndex</span> <span class="o">=</span> <span class="nx">p_nGroupIndex</span><span class="o">;</span>

                <span class="nx">oLI</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;groupindex&quot;</span><span class="o">,</span> <span class="nx">p_nGroupIndex</span><span class="o">);</span>
                <span class="nx">oLI</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;index&quot;</span><span class="o">,</span> <span class="nx">i</span><span class="o">);</span>

                <span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">oLI</span><span class="o">,</span> <span class="s2">&quot;first-of-type&quot;</span><span class="o">);</span>

            <span class="o">}</span>
    
        <span class="o">}</span>
        <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">oLI</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oLI</span><span class="o">,</span> <span class="s2">&quot;first-of-type&quot;</span><span class="o">);</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _createItemGroup</span>
<span class="c">* @description Creates a new menu item group (array) and its associated </span>
<span class="c">* &lt;code&gt;&amp;#60;ul&amp;#62;&lt;/code&gt; element. Returns an aray of menu item groups.</span>
<span class="c">* @private</span>
<span class="c">* @param {Number} p_nIndex Number indicating the group to create.</span>
<span class="c">* @return {Array}</span>
<span class="c">*/</span>
<span class="nx">_createItemGroup</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nIndex</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span><span class="o">[</span><span class="nx">p_nIndex</span><span class="o">])</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span><span class="o">[</span><span class="nx">p_nIndex</span><span class="o">]</span> <span class="o">=</span> <span class="o">[];</span>

        <span class="k">var</span> <span class="nx">oUL</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;ul&quot;</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">p_nIndex</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oUL</span><span class="o">;</span>

        <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span><span class="o">[</span><span class="nx">p_nIndex</span><span class="o">];</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _getItemGroup</span>
<span class="c">* @description Returns the menu item group at the specified index.</span>
<span class="c">* @private</span>
<span class="c">* @param {Number} p_nIndex Number indicating the index of the menu item group </span>
<span class="c">* to be retrieved.</span>
<span class="c">* @return {Array}</span>
<span class="c">*/</span>
<span class="nx">_getItemGroup</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nIndex</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">nIndex</span> <span class="o">=</span> <span class="o">((</span><span class="k">typeof</span> <span class="nx">p_nIndex</span> <span class="o">==</span> <span class="s2">&quot;number&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">p_nIndex</span> <span class="o">:</span> <span class="m">0</span><span class="o">);</span>

    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span><span class="o">[</span><span class="nx">nIndex</span><span class="o">];</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _configureSubmenu</span>
<span class="c">* @description Subscribes the menu item&#39;s submenu to its parent menu&#39;s events.</span>
<span class="c">* @private</span>
<span class="c">* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem </span>
<span class="c">* instance with the submenu to be configured.</span>
<span class="c">*/</span>
<span class="nx">_configureSubmenu</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">p_oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>
            
        <span class="c">/*</span>
<span class="c">            Listen for configuration changes to the parent menu </span>
<span class="c">            so they they can be applied to the submenu.</span>
<span class="c">        */</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">configChangedEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_onParentMenuConfigChange</span><span class="o">,</span> 
                <span class="nx">oSubmenu</span><span class="o">,</span> 
                <span class="kc">true</span>
            <span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">renderEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_onParentMenuRender</span><span class="o">,</span>
                <span class="nx">oSubmenu</span><span class="o">,</span> 
                <span class="kc">true</span>
            <span class="o">);</span>

        <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">beforeShowEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_onSubmenuBeforeShow</span><span class="o">,</span> 
                <span class="nx">oSubmenu</span><span class="o">,</span> 
                <span class="kc">true</span>
            <span class="o">);</span>

        <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">showEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onSubmenuShow</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">);</span>
        <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">hideEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onSubmenuHide</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _subscribeToItemEvents</span>
<span class="c">* @description Subscribes a menu to a menu item&#39;s event.</span>
<span class="c">* @private</span>
<span class="c">* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem </span>
<span class="c">* instance whose events should be subscribed to.</span>
<span class="c">*/</span>
<span class="nx">_subscribeToItemEvents</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>

    <span class="nx">p_oItem</span><span class="o">.</span><span class="nx">focusEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemFocus</span><span class="o">);</span>

    <span class="nx">p_oItem</span><span class="o">.</span><span class="nx">blurEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemBlur</span><span class="o">);</span>

    <span class="nx">p_oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">configChangedEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemConfigChange</span><span class="o">,</span>
        <span class="nx">p_oItem</span><span class="o">,</span>
        <span class="k">this</span>
    <span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _getOffsetWidth</span>
<span class="c">* @description Returns the offset width of the menu&#39;s </span>
<span class="c">* &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element.</span>
<span class="c">* @private</span>
<span class="c">*/</span>
<span class="nx">_getOffsetWidth</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oClone</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">cloneNode</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span>

    <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">oClone</span><span class="o">,</span> <span class="s2">&quot;width&quot;</span><span class="o">,</span> <span class="s2">&quot;&quot;</span><span class="o">);</span>

    <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oClone</span><span class="o">);</span>

    <span class="k">var</span> <span class="nx">sWidth</span> <span class="o">=</span> <span class="nx">oClone</span><span class="o">.</span><span class="nx">offsetWidth</span><span class="o">;</span>

    <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oClone</span><span class="o">);</span>

    <span class="k">return</span> <span class="nx">sWidth</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setWidth</span>
<span class="c">* @description Sets the width of the menu&#39;s root &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; </span>
<span class="c">* element to its offsetWidth.</span>
<span class="c">* @private</span>
<span class="c">*/</span>
<span class="nx">_setWidth</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sWidth</span><span class="o">;</span>

    <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;BODY&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">browser</span> <span class="o">==</span> <span class="s2">&quot;opera&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">sWidth</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getOffsetWidth</span><span class="o">();</span>
        
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;width&quot;</span><span class="o">,</span> <span class="s2">&quot;auto&quot;</span><span class="o">);</span>
            
            <span class="nx">sWidth</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetWidth</span><span class="o">;</span>
        
        <span class="o">}</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
    
        <span class="nx">sWidth</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getOffsetWidth</span><span class="o">();</span>
    
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;width&quot;</span><span class="o">,</span> <span class="o">(</span><span class="nx">sWidth</span> <span class="o">+</span> <span class="s2">&quot;px&quot;</span><span class="o">));</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onWidthChange</span>
<span class="c">* @description Change event handler for the the menu&#39;s &quot;width&quot; configuration</span>
<span class="c">* property.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onWidthChange</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sWidth</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
    
    <span class="k">if</span> <span class="o">(</span><span class="nx">sWidth</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_hasSetWidthHandlers</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">itemAddedEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setWidth</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">itemRemovedEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setWidth</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_hasSetWidthHandlers</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_hasSetWidthHandlers</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">itemAddedEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setWidth</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">itemRemovedEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setWidth</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_hasSetWidthHandlers</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onVisibleChange</span>
<span class="c">* @description Change event handler for the the menu&#39;s &quot;visible&quot; configuration</span>
<span class="c">* property.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onVisibleChange</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">bVisible</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
    
    <span class="k">if</span> <span class="o">(</span><span class="nx">bVisible</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;visible&quot;</span><span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;visible&quot;</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _cancelHideDelay</span>
<span class="c">* @description Cancels the call to &quot;hideMenu.&quot;</span>
<span class="c">* @private</span>
<span class="c">*/</span>
<span class="nx">_cancelHideDelay</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oRoot</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">();</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oRoot</span><span class="o">.</span><span class="nx">_nHideDelayId</span><span class="o">)</span> <span class="o">{</span>

        <span class="nb">window</span><span class="o">.</span><span class="nx">clearTimeout</span><span class="o">(</span><span class="nx">oRoot</span><span class="o">.</span><span class="nx">_nHideDelayId</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _execHideDelay</span>
<span class="c">* @description Hides the menu after the number of milliseconds specified by </span>
<span class="c">* the &quot;hidedelay&quot; configuration property.</span>
<span class="c">* @private</span>
<span class="c">*/</span>
<span class="nx">_execHideDelay</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_cancelHideDelay</span><span class="o">();</span>

    <span class="k">var</span> <span class="nx">oRoot</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">(),</span>
        <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

    <span class="k">function</span> <span class="nx">hideMenu</span><span class="o">()</span> <span class="o">{</span>
    
        <span class="k">if</span><span class="o">(</span><span class="nx">oRoot</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oRoot</span><span class="o">.</span><span class="nx">clearActiveItem</span><span class="o">();</span>

        <span class="o">}</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oRoot</span> <span class="o">==</span> <span class="nx">me</span> <span class="o">&amp;&amp;</span> <span class="nx">me</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;dynamic&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">me</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>            
        
        <span class="o">}</span>
    
    <span class="o">}</span>


    <span class="nx">oRoot</span><span class="o">.</span><span class="nx">_nHideDelayId</span> <span class="o">=</span> 
        <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="nx">hideMenu</span><span class="o">,</span> <span class="nx">oRoot</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;hidedelay&quot;</span><span class="o">));</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _cancelShowDelay</span>
<span class="c">* @description Cancels the call to the &quot;showMenu.&quot;</span>
<span class="c">* @private</span>
<span class="c">*/</span>
<span class="nx">_cancelShowDelay</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oRoot</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">();</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oRoot</span><span class="o">.</span><span class="nx">_nShowDelayId</span><span class="o">)</span> <span class="o">{</span>

        <span class="nb">window</span><span class="o">.</span><span class="nx">clearTimeout</span><span class="o">(</span><span class="nx">oRoot</span><span class="o">.</span><span class="nx">_nShowDelayId</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _execShowDelay</span>
<span class="c">* @description Shows the menu after the number of milliseconds specified by </span>
<span class="c">* the &quot;showdelay&quot; configuration property have ellapsed.</span>
<span class="c">* @private</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object specifying the menu that should </span>
<span class="c">* be made visible.</span>
<span class="c">*/</span>
<span class="nx">_execShowDelay</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oRoot</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">();</span>

    <span class="k">function</span> <span class="nx">showMenu</span><span class="o">()</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">))</span> <span class="o">{</span>

            <span class="nx">p_oMenu</span><span class="o">.</span><span class="nx">show</span><span class="o">();</span>

        <span class="o">}</span>

    <span class="o">}</span>


    <span class="nx">oRoot</span><span class="o">.</span><span class="nx">_nShowDelayId</span> <span class="o">=</span> 
        <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="nx">showMenu</span><span class="o">,</span> <span class="nx">oRoot</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;showdelay&quot;</span><span class="o">));</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _execSubmenuHideDelay</span>
<span class="c">* @description Hides a submenu after the number of milliseconds specified by </span>
<span class="c">* the &quot;submenuhidedelay&quot; configuration property have ellapsed.</span>
<span class="c">* @private</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oSubmenu Object specifying the submenu that  </span>
<span class="c">* should be hidden.</span>
<span class="c">* @param {Number} p_nMouseX The x coordinate of the mouse when it left </span>
<span class="c">* the specified submenu&#39;s parent menu item.</span>
<span class="c">* @param {Number} p_nHideDelay The number of milliseconds that should ellapse</span>
<span class="c">* before the submenu is hidden.</span>
<span class="c">*/</span>
<span class="nx">_execSubmenuHideDelay</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oSubmenu</span><span class="o">,</span> <span class="nx">p_nMouseX</span><span class="o">,</span> <span class="nx">p_nHideDelay</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

    <span class="nx">p_oSubmenu</span><span class="o">.</span><span class="nx">_nSubmenuHideDelayId</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span> <span class="o">()</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">me</span><span class="o">.</span><span class="nx">_nCurrentMouseX</span> <span class="o">&gt;</span> <span class="o">(</span><span class="nx">p_nMouseX</span> <span class="o">+</span> <span class="m">10</span><span class="o">))</span> <span class="o">{</span>

            <span class="nx">p_oSubmenu</span><span class="o">.</span><span class="nx">_nSubmenuHideDelayId</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
                <span class="nx">p_oSubmenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>

            <span class="o">},</span> <span class="nx">p_nHideDelay</span><span class="o">);</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="nx">p_oSubmenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
        
        <span class="o">}</span>

    <span class="o">},</span> <span class="m">50</span><span class="o">);</span>

<span class="o">},</span>



<span class="c">// Protected methods</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method _disableScrollHeader</span>
<span class="c">* @description Disables the header used for scrolling the body of the menu.</span>
<span class="c">* @protected</span>
<span class="c">*/</span>
<span class="nx">_disableScrollHeader</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_bHeaderDisabled</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">header</span><span class="o">,</span> <span class="s2">&quot;topscrollbar_disabled&quot;</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_bHeaderDisabled</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _disableScrollFooter</span>
<span class="c">* @description Disables the footer used for scrolling the body of the menu.</span>
<span class="c">* @protected</span>
<span class="c">*/</span>
<span class="nx">_disableScrollFooter</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_bFooterDisabled</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">footer</span><span class="o">,</span> <span class="s2">&quot;bottomscrollbar_disabled&quot;</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_bFooterDisabled</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _enableScrollHeader</span>
<span class="c">* @description Enables the header used for scrolling the body of the menu.</span>
<span class="c">* @protected</span>
<span class="c">*/</span>
<span class="nx">_enableScrollHeader</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_bHeaderDisabled</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">header</span><span class="o">,</span> <span class="s2">&quot;topscrollbar_disabled&quot;</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_bHeaderDisabled</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _enableScrollFooter</span>
<span class="c">* @description Enables the footer used for scrolling the body of the menu.</span>
<span class="c">* @protected</span>
<span class="c">*/</span>
<span class="nx">_enableScrollFooter</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_bFooterDisabled</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">footer</span><span class="o">,</span> <span class="s2">&quot;bottomscrollbar_disabled&quot;</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_bFooterDisabled</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMouseOver</span>
<span class="c">* @description &quot;mouseover&quot; event handler for the menu.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onMouseOver</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_bStopMouseEventHandlers</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
    
    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">oEvent</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
        <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">1</span><span class="o">],</span>
        <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>


    <span class="k">if</span><span class="o">(</span>
        <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_bHandledMouseOverEvent</span> <span class="o">&amp;&amp;</span> 
        <span class="o">(</span><span class="nx">oTarget</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span> <span class="o">||</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oTarget</span><span class="o">))</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="c">// Menu mouseover logic</span>
<span class="c"></span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_nCurrentMouseX</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> 
                <span class="s2">&quot;mousemove&quot;</span><span class="o">,</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseMove</span><span class="o">,</span> 
                <span class="k">this</span><span class="o">,</span> 
                <span class="kc">true</span>
            <span class="o">);</span>


        <span class="k">this</span><span class="o">.</span><span class="nx">clearActiveItem</span><span class="o">();</span>


        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_nSubmenuHideDelayId</span><span class="o">)</span> <span class="o">{</span>

            <span class="nb">window</span><span class="o">.</span><span class="nx">clearTimeout</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_nSubmenuHideDelayId</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

            <span class="k">var</span> <span class="nx">oParentMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span><span class="o">;</span>

            <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">_bHandledMouseOutEvent</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">_bHandledMouseOverEvent</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

        <span class="o">}</span>


        <span class="k">this</span><span class="o">.</span><span class="nx">_bHandledMouseOverEvent</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_bHandledMouseOutEvent</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    
    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span>
        <span class="nx">oItem</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">handledMouseOverEvent</span> <span class="o">&amp;&amp;</span> 
        <span class="o">!</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
        <span class="o">(</span><span class="nx">oTarget</span> <span class="o">==</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">element</span> <span class="o">||</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oTarget</span><span class="o">))</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="c">// Menu Item mouseover logic</span>
<span class="c"></span>
        <span class="k">var</span> <span class="nx">nShowDelay</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;showdelay&quot;</span><span class="o">),</span>
            <span class="nx">bShowDelay</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nShowDelay</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">);</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">bShowDelay</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">_cancelShowDelay</span><span class="o">();</span>
        
        <span class="o">}</span>


        <span class="k">var</span> <span class="nx">oActiveItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">;</span>
    
        <span class="k">if</span><span class="o">(</span><span class="nx">oActiveItem</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">oActiveItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
    
        <span class="o">}</span>


        <span class="k">var</span> <span class="nx">oItemCfg</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">;</span>
    
        <span class="c">// Select and focus the current menu item</span>
<span class="c"></span>    
        <span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>


        <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasFocus</span><span class="o">())</span> <span class="o">{</span>
        
            <span class="nx">oItem</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
        
        <span class="o">}</span>


        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;autosubmenudisplay&quot;</span><span class="o">))</span> <span class="o">{</span>

            <span class="c">// Show the submenu this menu item</span>
<span class="c"></span>
            <span class="k">var</span> <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>
        
            <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">if</span><span class="o">(</span><span class="nx">bShowDelay</span><span class="o">)</span> <span class="o">{</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">_execShowDelay</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">);</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>

                    <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">show</span><span class="o">();</span>

                <span class="o">}</span>

            <span class="o">}</span>

        <span class="o">}</span>                        

        <span class="nx">oItem</span><span class="o">.</span><span class="nx">handledMouseOverEvent</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        <span class="nx">oItem</span><span class="o">.</span><span class="nx">handledMouseOutEvent</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMouseOut</span>
<span class="c">* @description &quot;mouseout&quot; event handler for the menu.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onMouseOut</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_bStopMouseEventHandlers</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
    
    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">oEvent</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
        <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">1</span><span class="o">],</span>
        <span class="nx">oRelatedTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getRelatedTarget</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">),</span>
        <span class="nx">bMovingToSubmenu</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oItemCfg</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">,</span>
            <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>


        <span class="k">if</span><span class="o">(</span>
            <span class="nx">oSubmenu</span> <span class="o">&amp;&amp;</span> 
            <span class="o">(</span>
                <span class="nx">oRelatedTarget</span> <span class="o">==</span> <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">element</span> <span class="o">||</span>
                <span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oRelatedTarget</span><span class="o">)</span>
            <span class="o">)</span>
        <span class="o">)</span> <span class="o">{</span>

            <span class="nx">bMovingToSubmenu</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>

        <span class="o">}</span>


        <span class="k">if</span><span class="o">(</span> 
            <span class="o">!</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">handledMouseOutEvent</span> <span class="o">&amp;&amp;</span> 
            <span class="o">(</span>
                <span class="o">(</span>
                    <span class="nx">oRelatedTarget</span> <span class="o">!=</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">element</span> <span class="o">&amp;&amp;</span>  
                    <span class="o">!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oRelatedTarget</span><span class="o">)</span>
                <span class="o">)</span> <span class="o">||</span> <span class="nx">bMovingToSubmenu</span>
            <span class="o">)</span>
        <span class="o">)</span> <span class="o">{</span>

            <span class="c">// Menu Item mouseout logic</span>
<span class="c"></span>
            <span class="k">if</span><span class="o">(!</span><span class="nx">bMovingToSubmenu</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>


                <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>

                    <span class="k">var</span> <span class="nx">nSubmenuHideDelay</span> <span class="o">=</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenuhidedelay&quot;</span><span class="o">),</span>

                        <span class="nx">nShowDelay</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;showdelay&quot;</span><span class="o">);</span>

                    <span class="k">if</span><span class="o">(</span>
                        <span class="o">!(</span><span class="k">this</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuBar</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
                        <span class="nx">nSubmenuHideDelay</span> <span class="o">&gt;</span> <span class="m">0</span> <span class="o">&amp;&amp;</span> 
                        <span class="nx">nShowDelay</span> <span class="o">&gt;=</span> <span class="nx">nSubmenuHideDelay</span>
                    <span class="o">)</span> <span class="o">{</span>

                        <span class="k">this</span><span class="o">.</span><span class="nx">_execSubmenuHideDelay</span><span class="o">(</span>
                                <span class="nx">oSubmenu</span><span class="o">,</span> 
                                <span class="nx">Event</span><span class="o">.</span><span class="nx">getPageX</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">),</span>
                                <span class="nx">nSubmenuHideDelay</span>
                            <span class="o">);</span>

                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>

                        <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>

                    <span class="o">}</span>

                <span class="o">}</span>

            <span class="o">}</span>


            <span class="nx">oItem</span><span class="o">.</span><span class="nx">handledMouseOutEvent</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            <span class="nx">oItem</span><span class="o">.</span><span class="nx">handledMouseOverEvent</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    
        <span class="o">}</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span>
        <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_bHandledMouseOutEvent</span> <span class="o">&amp;&amp;</span> 
        <span class="o">(</span>
            <span class="o">(</span>
                <span class="nx">oRelatedTarget</span> <span class="o">!=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span> <span class="o">&amp;&amp;</span>  
                <span class="o">!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oRelatedTarget</span><span class="o">)</span>
            <span class="o">)</span> 
            <span class="o">||</span> <span class="nx">bMovingToSubmenu</span>
        <span class="o">)</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="c">// Menu mouseout logic</span>
<span class="c"></span>
        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;mousemove&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseMove</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_nCurrentMouseX</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getPageX</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_bHandledMouseOutEvent</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_bHandledMouseOverEvent</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMouseMove</span>
<span class="c">* @description &quot;click&quot; event handler for the menu.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onMouseMove</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_bStopMouseEventHandlers</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
    
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_nCurrentMouseX</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getPageX</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onClick</span>
<span class="c">* @description &quot;click&quot; event handler for the menu.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onClick</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oEvent</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
        <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">1</span><span class="o">],</span>
        <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oItemCfg</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">,</span>
            <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>


        <span class="c">/*</span>
<span class="c">            ACCESSIBILITY FEATURE FOR SCREEN READERS: </span>
<span class="c">            Expand/collapse the submenu when the user clicks </span>
<span class="c">            on the submenu indicator image.</span>
<span class="c">        */</span>        

        <span class="k">if</span><span class="o">(</span><span class="nx">oTarget</span> <span class="o">==</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">submenuIndicator</span> <span class="o">&amp;&amp;</span> <span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">))</span> <span class="o">{</span>

                <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
                
                <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
    
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">clearActiveItem</span><span class="o">();</span>

                <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

                <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">show</span><span class="o">();</span>
                
                <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">setInitialFocus</span><span class="o">();</span>
    
            <span class="o">}</span>
    
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">sURL</span> <span class="o">=</span> <span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;url&quot;</span><span class="o">),</span>
                <span class="nx">bCurrentPageURL</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sURL</span><span class="o">.</span><span class="nx">substr</span><span class="o">((</span><span class="nx">sURL</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">),</span><span class="m">1</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;#&quot;</span><span class="o">),</span>
                <span class="nx">sTarget</span> <span class="o">=</span> <span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;target&quot;</span><span class="o">),</span>
                <span class="nx">bHasTarget</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sTarget</span> <span class="o">&amp;&amp;</span> <span class="nx">sTarget</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">);</span>

            <span class="c">/*</span>
<span class="c">                Prevent the browser from following links </span>
<span class="c">                equal to &quot;#&quot;</span>
<span class="c">            */</span>
            
            <span class="k">if</span><span class="o">(</span>
                <span class="nx">oTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;A&quot;</span> <span class="o">&amp;&amp;</span> 
                <span class="nx">bCurrentPageURL</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">bHasTarget</span>
            <span class="o">)</span> <span class="o">{</span>

                <span class="nx">Event</span><span class="o">.</span><span class="nx">preventDefault</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>

                <span class="nx">oItem</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
            
            <span class="o">}</span>

            <span class="k">if</span><span class="o">(</span>
                <span class="nx">oTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;A&quot;</span> <span class="o">&amp;&amp;</span> 
                <span class="o">!</span><span class="nx">bCurrentPageURL</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">bHasTarget</span>
            <span class="o">)</span> <span class="o">{</span>
                
                <span class="c">/*</span>
<span class="c">                    Follow the URL of the item regardless of </span>
<span class="c">                    whether or not the user clicked specifically</span>
<span class="c">                    on the anchor element.</span>
<span class="c">                */</span>
    
                <span class="nb">document</span><span class="o">.</span><span class="nx">location</span> <span class="o">=</span> <span class="nx">sURL</span><span class="o">;</span>
        
            <span class="o">}</span>


            <span class="c">/*</span>
<span class="c">                If the item doesn&#39;t navigate to a URL and it doesn&#39;t have</span>
<span class="c">                a submenu, then collapse the menu tree.</span>
<span class="c">            */</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">bCurrentPageURL</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">var</span> <span class="nx">oRoot</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">();</span>
                
                <span class="k">if</span><span class="o">(</span><span class="nx">oRoot</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;static&quot;</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="nx">oRoot</span><span class="o">.</span><span class="nx">clearActiveItem</span><span class="o">();</span>
    
                <span class="o">}</span>
                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">oRoot</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;clicktohide&quot;</span><span class="o">))</span> <span class="o">{</span>

                    <span class="nx">oRoot</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
                
                <span class="o">}</span>
    
            <span class="o">}</span>

        <span class="o">}</span>                    
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onKeyDown</span>
<span class="c">* @description &quot;keydown&quot; event handler for the menu.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onKeyDown</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oEvent</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
        <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">1</span><span class="o">],</span>
        <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">,</span>
        <span class="nx">oSubmenu</span><span class="o">;</span>


    <span class="c">/*</span>
<span class="c">        This function is called to prevent a bug in Firefox.  In Firefox,</span>
<span class="c">        moving a DOM element into a stationary mouse pointer will cause the </span>
<span class="c">        browser to fire mouse events.  This can result in the menu mouse</span>
<span class="c">        event handlers being called uncessarily, especially when menus are </span>
<span class="c">        moved into a stationary mouse pointer as a result of a </span>
<span class="c">        key event handler.</span>
<span class="c">    */</span>
    <span class="k">function</span> <span class="nx">stopMouseEventHandlers</span><span class="o">()</span> <span class="o">{</span>

        <span class="nx">me</span><span class="o">.</span><span class="nx">_bStopMouseEventHandlers</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
        <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>
        
            <span class="nx">me</span><span class="o">.</span><span class="nx">_bStopMouseEventHandlers</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
        <span class="o">},</span> <span class="m">10</span><span class="o">);</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oItemCfg</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">,</span>
            <span class="nx">oParentItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">,</span>
            <span class="nx">oRoot</span><span class="o">,</span>
            <span class="nx">oNextItem</span><span class="o">;</span>


        <span class="nx">switch</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">.</span><span class="nx">keyCode</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">case</span> <span class="m">38</span><span class="o">:</span>    <span class="c">// Up arrow</span>
<span class="c"></span>            <span class="nx">case</span> <span class="m">40</span><span class="o">:</span>    <span class="c">// Down arrow</span>
<span class="c"></span>    
                <span class="nx">oNextItem</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oEvent</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">?</span> 
                    <span class="nx">oItem</span><span class="o">.</span><span class="nx">getPreviousEnabledSibling</span><span class="o">()</span> <span class="o">:</span> 
                    <span class="nx">oItem</span><span class="o">.</span><span class="nx">getNextEnabledSibling</span><span class="o">();</span>
        
                <span class="k">if</span><span class="o">(</span><span class="nx">oNextItem</span><span class="o">)</span> <span class="o">{</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">clearActiveItem</span><span class="o">();</span>

                    <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
                    <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>


                    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

                        <span class="k">var</span> <span class="nx">oBody</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">;</span>

                        <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">=</span> 

                            <span class="o">(</span>
                                <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetTop</span> <span class="o">+</span> 
                                <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetHeight</span>
                            <span class="o">)</span> <span class="o">-</span> <span class="nx">oBody</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">;</span>


                        <span class="k">var</span> <span class="nx">nScrollTop</span> <span class="o">=</span> <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span><span class="o">,</span>
                            <span class="nx">nScrollTarget</span> <span class="o">=</span> 
                                <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollHeight</span> <span class="o">-</span> <span class="nx">oBody</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">;</span>

                        <span class="k">if</span><span class="o">(</span><span class="nx">nScrollTop</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

                            <span class="k">this</span><span class="o">.</span><span class="nx">_disableScrollHeader</span><span class="o">();</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">_enableScrollFooter</span><span class="o">();</span>

                        <span class="o">}</span>
                        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">nScrollTop</span> <span class="o">==</span> <span class="nx">nScrollTarget</span><span class="o">)</span> <span class="o">{</span>

                             <span class="k">this</span><span class="o">.</span><span class="nx">_enableScrollHeader</span><span class="o">();</span>
                             <span class="k">this</span><span class="o">.</span><span class="nx">_disableScrollFooter</span><span class="o">();</span>

                        <span class="o">}</span>
                        <span class="k">else</span> <span class="o">{</span>

                            <span class="k">this</span><span class="o">.</span><span class="nx">_enableScrollHeader</span><span class="o">();</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">_enableScrollFooter</span><span class="o">();</span>

                        <span class="o">}</span>

                    <span class="o">}</span>

                <span class="o">}</span>

    
                <span class="nx">Event</span><span class="o">.</span><span class="nx">preventDefault</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>

                <span class="nx">stopMouseEventHandlers</span><span class="o">();</span>
    
            <span class="k">break</span><span class="o">;</span>
            
    
            <span class="nx">case</span> <span class="m">39</span><span class="o">:</span>    <span class="c">// Right arrow</span>
<span class="c"></span>    
                <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>
    
                <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">if</span><span class="o">(!</span><span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">))</span> <span class="o">{</span>
        
                        <span class="nx">oItemCfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        
                    <span class="o">}</span>
    
                    <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">show</span><span class="o">();</span>
                    <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">setInitialFocus</span><span class="o">();</span>
                    <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">setInitialSelection</span><span class="o">();</span>
    
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
    
                    <span class="nx">oRoot</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">();</span>
                    
                    <span class="k">if</span><span class="o">(</span><span class="nx">oRoot</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuBar</span><span class="o">)</span> <span class="o">{</span>
    
                        <span class="nx">oNextItem</span> <span class="o">=</span> <span class="nx">oRoot</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">.</span><span class="nx">getNextEnabledSibling</span><span class="o">();</span>
    
                        <span class="k">if</span><span class="o">(</span><span class="nx">oNextItem</span><span class="o">)</span> <span class="o">{</span>
                        
                            <span class="nx">oRoot</span><span class="o">.</span><span class="nx">clearActiveItem</span><span class="o">();</span>
    
                            <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    
                            <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>
    
                            <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>
    
                                <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">show</span><span class="o">();</span>
                            
                            <span class="o">}</span>
    
                            <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
                        
                        <span class="o">}</span>
                    
                    <span class="o">}</span>
                
                <span class="o">}</span>
    
    
                <span class="nx">Event</span><span class="o">.</span><span class="nx">preventDefault</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>

                <span class="nx">stopMouseEventHandlers</span><span class="o">();</span>

            <span class="k">break</span><span class="o">;</span>
    
    
            <span class="nx">case</span> <span class="m">37</span><span class="o">:</span>    <span class="c">// Left arrow</span>
<span class="c"></span>    
                <span class="k">if</span><span class="o">(</span><span class="nx">oParentItem</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">var</span> <span class="nx">oParentMenu</span> <span class="o">=</span> <span class="nx">oParentItem</span><span class="o">.</span><span class="nx">parent</span><span class="o">;</span>
    
                    <span class="k">if</span><span class="o">(</span><span class="nx">oParentMenu</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuBar</span><span class="o">)</span> <span class="o">{</span>
    
                        <span class="nx">oNextItem</span> <span class="o">=</span> 
                            <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">.</span><span class="nx">getPreviousEnabledSibling</span><span class="o">();</span>
    
                        <span class="k">if</span><span class="o">(</span><span class="nx">oNextItem</span><span class="o">)</span> <span class="o">{</span>
                        
                            <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">clearActiveItem</span><span class="o">();</span>
    
                            <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    
                            <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>
    
                            <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>
                            
                                <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">show</span><span class="o">();</span>
                            
                            <span class="o">}</span>
    
                            <span class="nx">oNextItem</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
                        
                        <span class="o">}</span> 
                    
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
    
                        <span class="k">this</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
    
                        <span class="nx">oParentItem</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
                    
                    <span class="o">}</span>
    
                <span class="o">}</span>
    
                <span class="nx">Event</span><span class="o">.</span><span class="nx">preventDefault</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>

                <span class="nx">stopMouseEventHandlers</span><span class="o">();</span>

            <span class="k">break</span><span class="o">;</span>        
    
        <span class="o">}</span>


    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">27</span><span class="o">)</span> <span class="o">{</span> <span class="c">// Esc key</span>
<span class="c"></span>
        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;dynamic&quot;</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>

            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
            
            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span> <span class="o">&amp;&amp;</span> <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">))</span> <span class="o">{</span>
            
                <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
            
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
        
            <span class="o">}</span>
        
        <span class="o">}</span>


        <span class="nx">Event</span><span class="o">.</span><span class="nx">preventDefault</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>
    
    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onKeyPress</span>
<span class="c">* @description &quot;keypress&quot; event handler for a Menu instance.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sType The name of the event that was fired.</span>
<span class="c">* @param {Array} p_aArgs Collection of arguments sent when the event </span>
<span class="c">* was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu The Menu instance that fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onKeyPress</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">var</span> <span class="nx">oEvent</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">40</span> <span class="o">||</span> <span class="nx">oEvent</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">preventDefault</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onTextResize</span>
<span class="c">* @description &quot;textresize&quot; event handler for the menu.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onTextResize</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">browser</span> <span class="o">==</span> <span class="s2">&quot;gecko&quot;</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_handleResize</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_handleResize</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        <span class="k">return</span><span class="o">;</span>
    
    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">oConfig</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;dynamic&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;width&quot;</span><span class="o">,</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_getOffsetWidth</span><span class="o">()</span> <span class="o">+</span> <span class="s2">&quot;px&quot;</span><span class="o">));</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onScrollTargetMouseOver</span>
<span class="c">* @description &quot;mouseover&quot; event handler for the menu&#39;s &quot;header&quot; and &quot;footer&quot; </span>
<span class="c">* elements.  Used to scroll the body of the menu up and down when the </span>
<span class="c">* menu&#39;s &quot;maxheight&quot; configuration property is set to a value greater than 0.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onScrollTargetMouseOver</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_cancelHideDelay</span><span class="o">();</span>

    <span class="k">var</span> <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">),</span>
        <span class="nx">oBody</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">,</span>
        <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">,</span>
        <span class="nx">nScrollTarget</span><span class="o">,</span>
        <span class="nx">fnScrollFunction</span><span class="o">;</span>


    <span class="k">function</span> <span class="nx">scrollBodyDown</span><span class="o">()</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">nScrollTop</span> <span class="o">=</span> <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span><span class="o">;</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">nScrollTop</span> <span class="o">&lt;</span> <span class="nx">nScrollTarget</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nScrollTop</span> <span class="o">+</span> <span class="m">1</span><span class="o">);</span>

            <span class="nx">me</span><span class="o">.</span><span class="nx">_enableScrollHeader</span><span class="o">();</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">=</span> <span class="nx">nScrollTarget</span><span class="o">;</span>
            
            <span class="nb">window</span><span class="o">.</span><span class="nx">clearInterval</span><span class="o">(</span><span class="nx">me</span><span class="o">.</span><span class="nx">_nBodyScrollId</span><span class="o">);</span>

            <span class="nx">me</span><span class="o">.</span><span class="nx">_disableScrollFooter</span><span class="o">();</span>

        <span class="o">}</span>

    <span class="o">}</span>


    <span class="k">function</span> <span class="nx">scrollBodyUp</span><span class="o">()</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">nScrollTop</span> <span class="o">=</span> <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span><span class="o">;</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">nScrollTop</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nScrollTop</span> <span class="o">-</span> <span class="m">1</span><span class="o">);</span>

            <span class="nx">me</span><span class="o">.</span><span class="nx">_enableScrollFooter</span><span class="o">();</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
            
            <span class="nb">window</span><span class="o">.</span><span class="nx">clearInterval</span><span class="o">(</span><span class="nx">me</span><span class="o">.</span><span class="nx">_nBodyScrollId</span><span class="o">);</span>

            <span class="nx">me</span><span class="o">.</span><span class="nx">_disableScrollHeader</span><span class="o">();</span>

        <span class="o">}</span>

    <span class="o">}</span>

    
    <span class="k">if</span><span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">oTarget</span><span class="o">,</span> <span class="s2">&quot;hd&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="nx">fnScrollFunction</span> <span class="o">=</span> <span class="nx">scrollBodyUp</span><span class="o">;</span>
    
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="nx">nScrollTarget</span> <span class="o">=</span> <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollHeight</span> <span class="o">-</span> <span class="nx">oBody</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">;</span>

        <span class="nx">fnScrollFunction</span> <span class="o">=</span> <span class="nx">scrollBodyDown</span><span class="o">;</span>
    
    <span class="o">}</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">_nBodyScrollId</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">setInterval</span><span class="o">(</span><span class="nx">fnScrollFunction</span><span class="o">,</span> <span class="m">10</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onScrollTargetMouseOut</span>
<span class="c">* @description &quot;mouseout&quot; event handler for the menu&#39;s &quot;header&quot; and &quot;footer&quot; </span>
<span class="c">* elements.  Used to stop scrolling the body of the menu up and down when the </span>
<span class="c">* menu&#39;s &quot;maxheight&quot; configuration property is set to a value greater than 0.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onScrollTargetMouseOut</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="nb">window</span><span class="o">.</span><span class="nx">clearInterval</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_nBodyScrollId</span><span class="o">);</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_cancelHideDelay</span><span class="o">();</span>

<span class="o">},</span>



<span class="c">// Private methods</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method _onInit</span>
<span class="c">* @description &quot;init&quot; event handler for the menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onInit</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">subscribeToConfigEvent</span><span class="o">(</span><span class="s2">&quot;width&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onWidthChange</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">subscribeToConfigEvent</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onVisibleChange</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span>
        <span class="o">(</span>
            <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">lazyLoad</span><span class="o">)</span> <span class="o">||</span> 
            <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;static&quot;</span><span class="o">)</span> <span class="o">||</span>
            <span class="o">(</span>
                <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> 
                <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">lazyLoad</span> <span class="o">&amp;&amp;</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;dynamic&quot;</span>
            <span class="o">)</span> 
        <span class="o">)</span> <span class="o">&amp;&amp;</span> 
        <span class="k">this</span><span class="o">.</span><span class="nx">getItemGroups</span><span class="o">().</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span>
    <span class="o">)</span> <span class="o">{</span>
 
        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_initSubTree</span><span class="o">();</span>
        
        <span class="o">}</span>


        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">itemData</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">addItems</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">itemData</span><span class="o">);</span>

        <span class="o">}</span>
    
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">lazyLoad</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">fireQueue</span><span class="o">();</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onBeforeRender</span>
<span class="c">* @description &quot;beforerender&quot; event handler for the menu.  Appends all of the </span>
<span class="c">* &lt;code&gt;&amp;#60;ul&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;li&amp;#62;&lt;/code&gt; and their accompanying </span>
<span class="c">* title elements to the body element of the menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onBeforeRender</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oConfig</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">,</span>
        <span class="nx">oEl</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span>
        <span class="nx">nListElements</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">nListElements</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span>
            <span class="nx">bFirstList</span> <span class="o">=</span> <span class="kc">true</span><span class="o">,</span>
            <span class="nx">oUL</span><span class="o">,</span>
            <span class="nx">oGroupTitle</span><span class="o">;</span>


        <span class="k">do</span> <span class="o">{</span>

            <span class="nx">oUL</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oUL</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">if</span><span class="o">(</span><span class="nx">bFirstList</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oUL</span><span class="o">,</span> <span class="s2">&quot;first-of-type&quot;</span><span class="o">);</span>
                    <span class="nx">bFirstList</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
                <span class="o">}</span>


                <span class="k">if</span><span class="o">(!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oEl</span><span class="o">,</span> <span class="nx">oUL</span><span class="o">))</span> <span class="o">{</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">appendToBody</span><span class="o">(</span><span class="nx">oUL</span><span class="o">);</span>

                <span class="o">}</span>


                <span class="nx">oGroupTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

                <span class="k">if</span><span class="o">(</span><span class="nx">oGroupTitle</span><span class="o">)</span> <span class="o">{</span>

                    <span class="k">if</span><span class="o">(!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oEl</span><span class="o">,</span> <span class="nx">oGroupTitle</span><span class="o">))</span> <span class="o">{</span>

                        <span class="nx">oUL</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">oGroupTitle</span><span class="o">,</span> <span class="nx">oUL</span><span class="o">);</span>

                    <span class="o">}</span>


                    <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oUL</span><span class="o">,</span> <span class="s2">&quot;hastitle&quot;</span><span class="o">);</span>

                <span class="o">}</span>

            <span class="o">}</span>

            <span class="nx">i</span><span class="o">++;</span>

        <span class="o">}</span>
        <span class="k">while</span><span class="o">(</span><span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">nListElements</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onRender</span>
<span class="c">* @description &quot;render&quot; event handler for the menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onRender</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span> <span class="o">(</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;dynamic&quot;</span> <span class="o">&amp;&amp;</span> 
        <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;width&quot;</span><span class="o">)</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_setWidth</span><span class="o">();</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onBeforeShow</span>
<span class="c">* @description &quot;beforeshow&quot; event handler for the menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onBeforeShow</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">lazyLoad</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">getItemGroups</span><span class="o">().</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">_initSubTree</span><span class="o">();</span>

        <span class="o">}</span>


        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">itemData</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">srcElement</span> <span class="o">&amp;&amp;</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span>
            <span class="o">)</span> <span class="o">{</span>

                <span class="k">var</span> <span class="nx">nOptions</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">itemData</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
    
                <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">n</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">n</span><span class="o">&lt;</span><span class="nx">nOptions</span><span class="o">;</span> <span class="nx">n</span><span class="o">++)</span> <span class="o">{</span>

                    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">itemData</span><span class="o">[</span><span class="nx">n</span><span class="o">].</span><span class="nx">tagName</span><span class="o">)</span> <span class="o">{</span>

                        <span class="k">this</span><span class="o">.</span><span class="nx">addItem</span><span class="o">((</span><span class="k">new</span> <span class="k">this</span><span class="o">.</span><span class="nx">ITEM_TYPE</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">itemData</span><span class="o">[</span><span class="nx">n</span><span class="o">])));</span>
    
                    <span class="o">}</span>
    
                <span class="o">}</span>
            
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">addItems</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">itemData</span><span class="o">);</span>
            
            <span class="o">}</span>
        
        <span class="o">}</span>


        <span class="k">var</span> <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">if</span><span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">))</span> <span class="o">{</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">);</span>
                
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                
                    <span class="k">this</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;container&quot;</span><span class="o">));</span>
                
                <span class="o">}</span>

            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">render</span><span class="o">();</span>

            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">element</span><span class="o">);</span>            

            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;container&quot;</span><span class="o">));</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">refireEvent</span><span class="o">(</span><span class="s2">&quot;xy&quot;</span><span class="o">);</span>

            <span class="o">}</span>                

        <span class="o">}</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;dynamic&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">nViewportHeight</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportHeight</span><span class="o">();</span>


        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuBar</span><span class="o">)</span> <span class="o">{</span>
           
            <span class="k">var</span> <span class="nx">oRegion</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Region</span><span class="o">.</span><span class="nx">getRegion</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">element</span><span class="o">);</span>
            
            <span class="nx">nViewportHeight</span> <span class="o">=</span> <span class="o">(</span><span class="nx">nViewportHeight</span> <span class="o">-</span> <span class="nx">oRegion</span><span class="o">.</span><span class="nx">bottom</span><span class="o">);</span>

        <span class="o">}</span>


        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetHeight</span> <span class="o">&gt;=</span> <span class="nx">nViewportHeight</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">var</span> <span class="nx">nMaxHeight</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">);</span>

            <span class="c">/*</span>
<span class="c">                Cache the original value for the &quot;maxheight&quot; configuration  </span>
<span class="c">                property so that we can set it back when the menu is hidden.</span>
<span class="c">            */</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">_nMaxHeight</span> <span class="o">=</span> <span class="nx">nMaxHeight</span><span class="o">;</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">,</span> <span class="o">(</span><span class="nx">nViewportHeight</span> <span class="o">-</span> <span class="m">20</span><span class="o">));</span>
        
        <span class="o">}</span>
    
    
        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">var</span> <span class="nx">oBody</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">;</span>
    
            <span class="k">if</span><span class="o">(</span><span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="nx">oBody</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
    
            <span class="o">}</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_disableScrollHeader</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_enableScrollFooter</span><span class="o">();</span>
    
        <span class="o">}</span>

    <span class="o">}</span>


<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onShow</span>
<span class="c">* @description &quot;show&quot; event handler for the menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that fired </span>
<span class="c">* the event.</span>
<span class="c">*/</span>
<span class="nx">_onShow</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oParent</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">;</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">oParent</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oParentMenu</span> <span class="o">=</span> <span class="nx">oParent</span><span class="o">.</span><span class="nx">parent</span><span class="o">,</span>
            <span class="nx">aParentAlignment</span> <span class="o">=</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenualignment&quot;</span><span class="o">),</span>
            <span class="nx">aAlignment</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenualignment&quot;</span><span class="o">);</span>


        <span class="k">if</span><span class="o">(</span>
            <span class="o">(</span><span class="nx">aParentAlignment</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">!=</span> <span class="nx">aAlignment</span><span class="o">[</span><span class="m">0</span><span class="o">])</span> <span class="o">&amp;&amp;</span>
            <span class="o">(</span><span class="nx">aParentAlignment</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">!=</span> <span class="nx">aAlignment</span><span class="o">[</span><span class="m">1</span><span class="o">])</span>
        <span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span>
                <span class="s2">&quot;submenualignment&quot;</span><span class="o">,</span> 
                <span class="o">[</span> <span class="nx">aParentAlignment</span><span class="o">[</span><span class="m">0</span><span class="o">],</span> <span class="nx">aParentAlignment</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">]</span>
            <span class="o">);</span>
        
        <span class="o">}</span>


        <span class="k">if</span><span class="o">(</span>
            <span class="o">!</span><span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;autosubmenudisplay&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
            <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;static&quot;</span>
        <span class="o">)</span> <span class="o">{</span>

            <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;autosubmenudisplay&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>


            <span class="k">function</span> <span class="nx">disableAutoSubmenuDisplay</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">if</span><span class="o">(</span>
                    <span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;mousedown&quot;</span> <span class="o">||</span> 
                    <span class="o">(</span><span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;keydown&quot;</span> <span class="o">&amp;&amp;</span> <span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">27</span><span class="o">)</span>
                <span class="o">)</span> <span class="o">{</span>

                    <span class="c">/*  </span>
<span class="c">                        Set the &quot;autosubmenudisplay&quot; to &quot;false&quot; if the user</span>
<span class="c">                        clicks outside the menu bar.</span>
<span class="c">                    */</span>

                    <span class="k">var</span> <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>

                    <span class="k">if</span><span class="o">(</span>
                        <span class="nx">oTarget</span> <span class="o">!=</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">element</span> <span class="o">||</span> 
                        <span class="o">!</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oTarget</span><span class="o">)</span>
                    <span class="o">)</span> <span class="o">{</span>

                        <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span>
                            <span class="s2">&quot;autosubmenudisplay&quot;</span><span class="o">,</span> 
                            <span class="kc">false</span>
                        <span class="o">);</span>

                        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span>
                                <span class="nb">document</span><span class="o">,</span> 
                                <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> 
                                <span class="nx">disableAutoSubmenuDisplay</span>
                            <span class="o">);</span>

                        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span>
                                <span class="nb">document</span><span class="o">,</span> 
                                <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> 
                                <span class="nx">disableAutoSubmenuDisplay</span>
                            <span class="o">);</span>

                    <span class="o">}</span>
                
                <span class="o">}</span>

            <span class="o">}</span>

            <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> <span class="nx">disableAutoSubmenuDisplay</span><span class="o">);</span>                             
            <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> <span class="nx">disableAutoSubmenuDisplay</span><span class="o">);</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onBeforeHide</span>
<span class="c">* @description &quot;beforehide&quot; event handler for the menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that fired </span>
<span class="c">* the event.</span>
<span class="c">*/</span>
<span class="nx">_onBeforeHide</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oActiveItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oActiveItem</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oConfig</span> <span class="o">=</span> <span class="nx">oActiveItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">;</span>

        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>

        <span class="k">var</span> <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>

        <span class="o">}</span>

    <span class="o">}</span>

    <span class="k">if</span> <span class="o">(</span><span class="k">this</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">())</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onHide</span>
<span class="c">* @description &quot;hide&quot; event handler for the menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that fired </span>
<span class="c">* the event.</span>
<span class="c">*/</span>
<span class="nx">_onHide</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_nMaxHeight</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_nMaxHeight</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_nMaxHeight</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onParentMenuConfigChange</span>
<span class="c">* @description &quot;configchange&quot; event handler for a submenu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oSubmenu Object representing the submenu that </span>
<span class="c">* subscribed to the event.</span>
<span class="c">*/</span>
<span class="nx">_onParentMenuConfigChange</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oSubmenu</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">var</span> <span class="nx">sPropertyName</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">][</span><span class="m">0</span><span class="o">],</span>
        <span class="nx">oPropertyValue</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">][</span><span class="m">1</span><span class="o">];</span>

    <span class="nx">switch</span><span class="o">(</span><span class="nx">sPropertyName</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">case</span> <span class="s2">&quot;iframe&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;constraintoviewport&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;hidedelay&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;showdelay&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;submenuhidedelay&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;clicktohide&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;effect&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;classname&quot;</span><span class="o">:</span>

            <span class="nx">p_oSubmenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="nx">sPropertyName</span><span class="o">,</span> <span class="nx">oPropertyValue</span><span class="o">);</span>
                
        <span class="k">break</span><span class="o">;</span>        
        
    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onParentMenuRender</span>
<span class="c">* @description &quot;render&quot; event handler for a submenu.  Renders a  </span>
<span class="c">* submenu in response to the firing of its parent&#39;s &quot;render&quot; event.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oSubmenu Object representing the submenu that </span>
<span class="c">* subscribed to the event.</span>
<span class="c">*/</span>
<span class="nx">_onParentMenuRender</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oSubmenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oParentMenu</span> <span class="o">=</span> <span class="nx">p_oSubmenu</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span><span class="o">,</span>

        <span class="nx">oConfig</span> <span class="o">=</span> <span class="o">{</span>

            <span class="nx">constraintoviewport</span><span class="o">:</span> 
                <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;constraintoviewport&quot;</span><span class="o">),</span>

            <span class="nx">xy</span><span class="o">:</span> <span class="o">[</span><span class="m">0</span><span class="o">,</span><span class="m">0</span><span class="o">],</span>
                
            <span class="nx">clicktohide</span><span class="o">:</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;clicktohide&quot;</span><span class="o">),</span>
                
            <span class="nx">effect</span><span class="o">:</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;effect&quot;</span><span class="o">),</span>

            <span class="nx">showdelay</span><span class="o">:</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;showdelay&quot;</span><span class="o">),</span>
            
            <span class="nx">hidedelay</span><span class="o">:</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;hidedelay&quot;</span><span class="o">),</span>

            <span class="nx">submenuhidedelay</span><span class="o">:</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenuhidedelay&quot;</span><span class="o">),</span>

            <span class="nx">classname</span><span class="o">:</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;classname&quot;</span><span class="o">)</span>

        <span class="o">};</span>


    <span class="c">/*</span>
<span class="c">        Only sync the &quot;iframe&quot; configuration property if the parent</span>
<span class="c">        menu&#39;s &quot;position&quot; configuration is the same.</span>
<span class="c">    */</span>

    <span class="k">if</span><span class="o">(</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> 
        <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">iframe</span> <span class="o">=</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;iframe&quot;</span><span class="o">);</span>
    
    <span class="o">}</span>
               

    <span class="nx">p_oSubmenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">applyConfig</span><span class="o">(</span><span class="nx">oConfig</span><span class="o">);</span>


    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">lazyLoad</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oLI</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">element</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span> <span class="o">==</span> <span class="nx">oLI</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">render</span><span class="o">();</span>
    
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="nx">oLI</span><span class="o">);</span>
    
        <span class="o">}</span>

    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onSubmenuBeforeShow</span>
<span class="c">* @description &quot;beforeshow&quot; event handler for a submenu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oSubmenu Object representing the submenu that </span>
<span class="c">* subscribed to the event.</span>
<span class="c">*/</span>
<span class="nx">_onSubmenuBeforeShow</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oSubmenu</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">var</span> <span class="nx">oParent</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">,</span>
        <span class="nx">aAlignment</span> <span class="o">=</span> <span class="nx">oParent</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenualignment&quot;</span><span class="o">);</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span>
        <span class="s2">&quot;context&quot;</span><span class="o">,</span> 
        <span class="o">[</span><span class="nx">oParent</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">aAlignment</span><span class="o">[</span><span class="m">0</span><span class="o">],</span> <span class="nx">aAlignment</span><span class="o">[</span><span class="m">1</span><span class="o">]]</span>
    <span class="o">);</span>


    <span class="k">var</span> <span class="nx">nScrollTop</span> <span class="o">=</span> <span class="nx">oParent</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">scrollTop</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span>
        <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">browser</span> <span class="o">==</span> <span class="s2">&quot;gecko&quot;</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">browser</span> <span class="o">==</span> <span class="s2">&quot;safari&quot;</span><span class="o">)</span> 
        <span class="o">&amp;&amp;</span> <span class="nx">nScrollTop</span> <span class="o">&gt;</span> <span class="m">0</span>
    <span class="o">)</span> <span class="o">{</span>

         <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;y&quot;</span><span class="o">,</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;y&quot;</span><span class="o">)</span> <span class="o">-</span> <span class="nx">nScrollTop</span><span class="o">));</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onSubmenuShow</span>
<span class="c">* @description &quot;show&quot; event handler for a submenu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onSubmenuShow</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">this</span><span class="o">.</span><span class="nx">submenuIndicator</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">.</span><span class="nx">nodeValue</span> <span class="o">=</span> 
        <span class="k">this</span><span class="o">.</span><span class="nx">EXPANDED_SUBMENU_INDICATOR_TEXT</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onSubmenuHide</span>
<span class="c">* @description &quot;hide&quot; Custom Event handler for a submenu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onSubmenuHide</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">this</span><span class="o">.</span><span class="nx">submenuIndicator</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">.</span><span class="nx">nodeValue</span> <span class="o">=</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">COLLAPSED_SUBMENU_INDICATOR_TEXT</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuItemFocus</span>
<span class="c">* @description &quot;focus&quot; event handler for the menu&#39;s items.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onMenuItemFocus</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">focusEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuItemBlur</span>
<span class="c">* @description &quot;blur&quot; event handler for the menu&#39;s items.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event </span>
<span class="c">* that was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onMenuItemBlur</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">blurEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuItemConfigChange</span>
<span class="c">* @description &quot;configchange&quot; event handler for the menu&#39;s items.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.MenuItem} p_oItem Object representing the menu item </span>
<span class="c">* that fired the event.</span>
<span class="c">*/</span>
<span class="nx">_onMenuItemConfigChange</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sPropertyName</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">][</span><span class="m">0</span><span class="o">],</span>
        <span class="nx">oPropertyValue</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">][</span><span class="m">1</span><span class="o">];</span>

    <span class="nx">switch</span><span class="o">(</span><span class="nx">sPropertyName</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">case</span> <span class="s2">&quot;selected&quot;</span><span class="o">:</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">oPropertyValue</span> <span class="o">===</span> <span class="kc">true</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span> <span class="o">=</span> <span class="nx">p_oItem</span><span class="o">;</span>
            
            <span class="o">}</span>

        <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;submenu&quot;</span><span class="o">:</span>

            <span class="k">var</span> <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">][</span><span class="m">1</span><span class="o">];</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">_configureSubmenu</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">);</span>

            <span class="o">}</span>

        <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;text&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;helptext&quot;</span><span class="o">:</span>

            <span class="c">/*</span>
<span class="c">                A change to an item&#39;s &quot;text&quot; or &quot;helptext&quot;</span>
<span class="c">                configuration properties requires the width of the parent</span>
<span class="c">                menu to be recalculated.</span>
<span class="c">            */</span>

            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">width</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">var</span> <span class="nx">sWidth</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getOffsetWidth</span><span class="o">()</span> <span class="o">+</span> <span class="s2">&quot;px&quot;</span><span class="o">;</span>

                <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;width&quot;</span><span class="o">,</span> <span class="nx">sWidth</span><span class="o">);</span>

            <span class="o">}</span>

        <span class="k">break</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>



<span class="c">// Public event handlers for configuration properties</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method enforceConstraints</span>
<span class="c">* @description The default event handler executed when the moveEvent is fired,  </span>
<span class="c">* if the &quot;constraintoviewport&quot; configuration property is set to true.</span>
<span class="c">* @param {String} type The name of the event that was fired.</span>
<span class="c">* @param {Array} args Collection of arguments sent when the </span>
<span class="c">* event was fired.</span>
<span class="c">* @param {Array} obj Array containing the current Menu instance </span>
<span class="c">* and the item that fired the event.</span>
<span class="c">*/</span>
<span class="nx">enforceConstraints</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">args</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> <span class="o">!(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuBar</span><span class="o">))</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">oConfig</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">,</span>
            <span class="nx">pos</span> <span class="o">=</span> <span class="nx">args</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
            
            <span class="nx">x</span> <span class="o">=</span> <span class="nx">pos</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
            <span class="nx">y</span> <span class="o">=</span> <span class="nx">pos</span><span class="o">[</span><span class="m">1</span><span class="o">],</span>
            
            <span class="nx">offsetHeight</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">,</span>
            <span class="nx">offsetWidth</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetWidth</span><span class="o">,</span>
            
            <span class="nx">viewPortWidth</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportWidth</span><span class="o">(),</span>
            <span class="nx">viewPortHeight</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportHeight</span><span class="o">(),</span>
            
            <span class="nx">scrollX</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span>
                    <span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">scrollLeft</span><span class="o">,</span> 
                    <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">scrollLeft</span>
                <span class="o">),</span>
            
            <span class="nx">scrollY</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span>
                    <span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">scrollTop</span><span class="o">,</span> 
                    <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">scrollTop</span>
                <span class="o">),</span>
            
            <span class="nx">nPadding</span> <span class="o">=</span> <span class="o">(</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">&amp;&amp;</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuBar</span>
                        <span class="o">)</span> <span class="o">?</span> <span class="m">0</span> <span class="o">:</span> <span class="m">10</span><span class="o">,</span>
            
            <span class="nx">topConstraint</span> <span class="o">=</span> <span class="nx">scrollY</span> <span class="o">+</span> <span class="nx">nPadding</span><span class="o">,</span>
            <span class="nx">leftConstraint</span> <span class="o">=</span> <span class="nx">scrollX</span> <span class="o">+</span> <span class="nx">nPadding</span><span class="o">,</span>
            <span class="nx">bottomConstraint</span> <span class="o">=</span> 
                <span class="nx">scrollY</span> <span class="o">+</span> <span class="nx">viewPortHeight</span> <span class="o">-</span> <span class="nx">offsetHeight</span> <span class="o">-</span> <span class="nx">nPadding</span><span class="o">,</span>
            <span class="nx">rightConstraint</span> <span class="o">=</span> <span class="nx">scrollX</span> <span class="o">+</span> <span class="nx">viewPortWidth</span> <span class="o">-</span> <span class="nx">offsetWidth</span> <span class="o">-</span> <span class="nx">nPadding</span><span class="o">,</span>
            
            <span class="nx">aContext</span> <span class="o">=</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;context&quot;</span><span class="o">),</span>
            <span class="nx">oContextElement</span> <span class="o">=</span> <span class="nx">aContext</span> <span class="o">?</span> <span class="nx">aContext</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
    
    
        <span class="k">if</span> <span class="o">(</span><span class="nx">x</span> <span class="o">&lt;</span> <span class="m">10</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">x</span> <span class="o">=</span> <span class="nx">leftConstraint</span><span class="o">;</span>
    
        <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">((</span><span class="nx">x</span> <span class="o">+</span> <span class="nx">offsetWidth</span><span class="o">)</span> <span class="o">&gt;</span> <span class="nx">viewPortWidth</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">if</span><span class="o">(</span>
                <span class="nx">oContextElement</span> <span class="o">&amp;&amp;</span>
                <span class="o">((</span><span class="nx">x</span> <span class="o">-</span> <span class="nx">oContextElement</span><span class="o">.</span><span class="nx">offsetWidth</span><span class="o">)</span> <span class="o">&gt;</span> <span class="nx">offsetWidth</span><span class="o">)</span>
            <span class="o">)</span> <span class="o">{</span>
    
                <span class="nx">x</span> <span class="o">=</span> <span class="o">(</span><span class="nx">x</span> <span class="o">-</span> <span class="o">(</span><span class="nx">oContextElement</span><span class="o">.</span><span class="nx">offsetWidth</span> <span class="o">+</span> <span class="nx">offsetWidth</span><span class="o">));</span>
    
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
    
                <span class="nx">x</span> <span class="o">=</span> <span class="nx">rightConstraint</span><span class="o">;</span>
    
            <span class="o">}</span>
    
        <span class="o">}</span>
    
        <span class="k">if</span> <span class="o">(</span><span class="nx">y</span> <span class="o">&lt;</span> <span class="m">10</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">y</span> <span class="o">=</span> <span class="nx">topConstraint</span><span class="o">;</span>
    
        <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">y</span> <span class="o">&gt;</span> <span class="nx">bottomConstraint</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">if</span><span class="o">(</span><span class="nx">oContextElement</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">y</span> <span class="o">&gt;</span> <span class="nx">offsetHeight</span><span class="o">))</span> <span class="o">{</span>
    
                <span class="nx">y</span> <span class="o">=</span> <span class="o">((</span><span class="nx">y</span> <span class="o">+</span> <span class="nx">oContextElement</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">)</span> <span class="o">-</span> <span class="nx">offsetHeight</span><span class="o">);</span>
    
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
    
                <span class="nx">y</span> <span class="o">=</span> <span class="nx">bottomConstraint</span><span class="o">;</span>
    
            <span class="o">}</span>
    
        <span class="o">}</span>
    
        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;x&quot;</span><span class="o">,</span> <span class="nx">x</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;y&quot;</span><span class="o">,</span> <span class="nx">y</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;xy&quot;</span><span class="o">,</span> <span class="o">[</span><span class="nx">x</span><span class="o">,</span><span class="nx">y</span><span class="o">],</span> <span class="kc">true</span><span class="o">);</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method configVisible</span>
<span class="c">* @description Event handler for when the &quot;visible&quot; configuration property </span>
<span class="c">* the menu changes.</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">configVisible</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;dynamic&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">configVisible</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span>
            <span class="k">this</span><span class="o">,</span> 
            <span class="nx">p_sType</span><span class="o">,</span> 
            <span class="nx">p_aArgs</span><span class="o">,</span> 
            <span class="nx">p_oMenu</span>
        <span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">bVisible</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
    	    <span class="nx">sDisplay</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;display&quot;</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">bVisible</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">sDisplay</span> <span class="o">!=</span> <span class="s2">&quot;block&quot;</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">beforeShowEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
                <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;display&quot;</span><span class="o">,</span> <span class="s2">&quot;block&quot;</span><span class="o">);</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">showEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
            <span class="o">}</span>
        
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

			<span class="k">if</span><span class="o">(</span><span class="nx">sDisplay</span> <span class="o">==</span> <span class="s2">&quot;block&quot;</span><span class="o">)</span> <span class="o">{</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">beforeHideEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
				<span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;display&quot;</span><span class="o">,</span> <span class="s2">&quot;none&quot;</span><span class="o">);</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">hideEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
			<span class="o">}</span>
        
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method configPosition</span>
<span class="c">* @description Event handler for when the &quot;position&quot; configuration property </span>
<span class="c">* of the menu changes.</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">configPosition</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sCSSPosition</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">==</span> <span class="s2">&quot;static&quot;</span> <span class="o">?</span> <span class="s2">&quot;static&quot;</span> <span class="o">:</span> <span class="s2">&quot;absolute&quot;</span><span class="o">,</span>
        <span class="nx">oCfg</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">;</span>

    <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;position&quot;</span><span class="o">,</span> <span class="nx">sCSSPosition</span><span class="o">);</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">sCSSPosition</span> <span class="o">==</span> <span class="s2">&quot;static&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="c">/*</span>
<span class="c">            Remove the iframe for statically positioned menus since it will </span>
<span class="c">            intercept mouse events.</span>
<span class="c">        */</span>

        <span class="nx">oCfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;iframe&quot;</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>


        <span class="c">// Statically positioned menus are visible by default</span>
<span class="c"></span>        
        <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;display&quot;</span><span class="o">,</span> <span class="s2">&quot;block&quot;</span><span class="o">);</span>

        <span class="nx">oCfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="c">/*</span>
<span class="c">            Even though the &quot;visible&quot; property is queued to </span>
<span class="c">            &quot;false&quot; by default, we need to set the &quot;visibility&quot; property to </span>
<span class="c">            &quot;hidden&quot; since Overlay&#39;s &quot;configVisible&quot; implementation checks the </span>
<span class="c">            element&#39;s &quot;visibility&quot; style property before deciding whether </span>
<span class="c">            or not to show an Overlay instance.</span>
<span class="c">        */</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="s2">&quot;visibility&quot;</span><span class="o">,</span> <span class="s2">&quot;hidden&quot;</span><span class="o">);</span>
    
    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">sCSSPosition</span> <span class="o">==</span> <span class="s2">&quot;absolute&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">nZIndex</span> <span class="o">=</span> <span class="nx">oCfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;zindex&quot;</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(!</span><span class="nx">nZIndex</span> <span class="o">||</span> <span class="nx">nZIndex</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">nZIndex</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span> <span class="o">?</span> 
                <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">parent</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;zindex&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="m">1</span><span class="o">)</span> <span class="o">:</span> <span class="m">1</span><span class="o">;</span>

            <span class="nx">oCfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;zindex&quot;</span><span class="o">,</span> <span class="nx">nZIndex</span><span class="o">);</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method configIframe</span>
<span class="c">* @description Event handler for when the &quot;iframe&quot; configuration property of </span>
<span class="c">* the menu changes.</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">configIframe</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>    

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;position&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;dynamic&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">configIframe</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span>
            <span class="k">this</span><span class="o">,</span> 
            <span class="nx">p_sType</span><span class="o">,</span> 
            <span class="nx">p_aArgs</span><span class="o">,</span> 
            <span class="nx">p_oMenu</span>
        <span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method configHideDelay</span>
<span class="c">* @description Event handler for when the &quot;hidedelay&quot; configuration property </span>
<span class="c">* of the menu changes.</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">configHideDelay</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">nHideDelay</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
        <span class="nx">oMouseOutEvent</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">mouseOutEvent</span><span class="o">,</span>
        <span class="nx">oMouseOverEvent</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">mouseOverEvent</span><span class="o">,</span>
        <span class="nx">oKeyDownEvent</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">keyDownEvent</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">nHideDelay</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

        <span class="c">/*</span>
<span class="c">            Only assign event handlers once. This way the user change </span>
<span class="c">            the value for the hidedelay as many times as they want.</span>
<span class="c">        */</span>

        <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_bHideDelayEventHandlersAssigned</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oMouseOutEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_execHideDelay</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
            <span class="nx">oMouseOverEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_cancelHideDelay</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">oKeyDownEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_cancelHideDelay</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_bHideDelayEventHandlersAssigned</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
        <span class="o">}</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="nx">oMouseOutEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_execHideDelay</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        <span class="nx">oMouseOverEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_cancelHideDelay</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        <span class="nx">oKeyDownEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_cancelHideDelay</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_bHideDelayEventHandlersAssigned</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method configContainer</span>
<span class="c">* @description Event handler for when the &quot;container&quot; configuration property </span>
<span class="c">of the menu changes.</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that </span>
<span class="c">* fired the event.</span>
<span class="c">*/</span>
<span class="nx">configContainer</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

	<span class="k">var</span> <span class="nx">oElement</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

	<span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">oElement</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span>
                <span class="s2">&quot;container&quot;</span><span class="o">,</span> 
                <span class="nb">document</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">oElement</span><span class="o">),</span> 
                <span class="kc">true</span>
            <span class="o">);</span>

	<span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setMaxHeight</span>
<span class="c">* @description &quot;renderEvent&quot; handler used to defer the setting of the </span>
<span class="c">* &quot;maxheight&quot; configuration property until the menu is rendered in lazy </span>
<span class="c">* load scenarios.</span>
<span class="c">* @param {String} p_sType The name of the event that was fired.</span>
<span class="c">* @param {Array} p_aArgs Collection of arguments sent when the event </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Number} p_nMaxHeight Number representing the value to set for the </span>
<span class="c">* &quot;maxheight&quot; configuration property.</span>
<span class="c">* @private</span>
<span class="c">*/</span>
<span class="nx">_setMaxHeight</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_nMaxHeight</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">,</span> <span class="nx">p_nMaxHeight</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">renderEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setMaxHeight</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method configMaxHeight</span>
<span class="c">* @description Event handler for when the &quot;maxheight&quot; configuration property of </span>
<span class="c">* a Menu changes.</span>
<span class="c">* @param {String} p_sType The name of the event that was fired.</span>
<span class="c">* @param {Array} p_aArgs Collection of arguments sent when the event </span>
<span class="c">* was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu The Menu instance fired</span>
<span class="c">* the event.</span>
<span class="c">*/</span>
<span class="nx">configMaxHeight</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">nMaxHeight</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">],</span>
        <span class="nx">oBody</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">;</span>


    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">lazyLoad</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oBody</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">renderEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setMaxHeight</span><span class="o">);</span>
    
        <span class="k">if</span><span class="o">(</span><span class="nx">nMaxHeight</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">renderEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setMaxHeight</span><span class="o">,</span> <span class="nx">nMaxHeight</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

        <span class="o">}</span>

        <span class="k">return</span><span class="o">;</span>
    
    <span class="o">}</span>

    <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">oBody</span><span class="o">,</span> <span class="s2">&quot;height&quot;</span><span class="o">,</span> <span class="s2">&quot;auto&quot;</span><span class="o">);</span>
    <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">oBody</span><span class="o">,</span> <span class="s2">&quot;overflow&quot;</span><span class="o">,</span> <span class="s2">&quot;visible&quot;</span><span class="o">);</span>    

    <span class="k">var</span> <span class="nx">oHeader</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">header</span><span class="o">,</span>
        <span class="nx">oFooter</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">footer</span><span class="o">,</span>
        <span class="nx">fnMouseOver</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onScrollTargetMouseOver</span><span class="o">,</span>
        <span class="nx">fnMouseOut</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onScrollTargetMouseOut</span><span class="o">;</span>


    <span class="k">if</span><span class="o">((</span><span class="nx">nMaxHeight</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oBody</span><span class="o">.</span><span class="nx">offsetHeight</span> <span class="o">&gt;</span> <span class="nx">nMaxHeight</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;width&quot;</span><span class="o">))</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_setWidth</span><span class="o">();</span>

        <span class="o">}</span>

        <span class="k">if</span><span class="o">(!</span><span class="nx">oHeader</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oFooter</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">setHeader</span><span class="o">(</span><span class="s2">&quot;&amp;#32;&quot;</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">setFooter</span><span class="o">(</span><span class="s2">&quot;&amp;#32;&quot;</span><span class="o">);</span>

            <span class="nx">oHeader</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">header</span><span class="o">;</span>
            <span class="nx">oFooter</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">footer</span><span class="o">;</span>

            <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">,</span> <span class="s2">&quot;topscrollbar&quot;</span><span class="o">);</span>
            <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">,</span> <span class="s2">&quot;bottomscrollbar&quot;</span><span class="o">);</span>
            
            <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">,</span> <span class="nx">oBody</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">);</span>

            <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">,</span> <span class="s2">&quot;mouseover&quot;</span><span class="o">,</span> <span class="nx">fnMouseOver</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">,</span> <span class="s2">&quot;mouseout&quot;</span><span class="o">,</span> <span class="nx">fnMouseOut</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">,</span> <span class="s2">&quot;mouseover&quot;</span><span class="o">,</span> <span class="nx">fnMouseOver</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">,</span> <span class="s2">&quot;mouseout&quot;</span><span class="o">,</span> <span class="nx">fnMouseOut</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        
        <span class="o">}</span>

        <span class="k">var</span> <span class="nx">nHeight</span> <span class="o">=</span> 

                <span class="o">(</span>
                    <span class="nx">nMaxHeight</span> <span class="o">-</span> 
                    <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">footer</span><span class="o">.</span><span class="nx">offsetHeight</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">header</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">)</span>
                <span class="o">);</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">oBody</span><span class="o">,</span> <span class="s2">&quot;height&quot;</span><span class="o">,</span> <span class="o">(</span><span class="nx">nHeight</span> <span class="o">+</span> <span class="s2">&quot;px&quot;</span><span class="o">));</span>
        <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">oBody</span><span class="o">,</span> <span class="s2">&quot;overflow&quot;</span><span class="o">,</span> <span class="s2">&quot;hidden&quot;</span><span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">oHeader</span> <span class="o">&amp;&amp;</span> <span class="nx">oFooter</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">oBody</span><span class="o">,</span> <span class="s2">&quot;height&quot;</span><span class="o">,</span> <span class="s2">&quot;auto&quot;</span><span class="o">);</span>
        <span class="nx">Dom</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">oBody</span><span class="o">,</span> <span class="s2">&quot;overflow&quot;</span><span class="o">,</span> <span class="s2">&quot;visible&quot;</span><span class="o">);</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">,</span> <span class="s2">&quot;mouseover&quot;</span><span class="o">,</span> <span class="nx">fnMouseOver</span><span class="o">);</span>
        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">,</span> <span class="s2">&quot;mouseout&quot;</span><span class="o">,</span> <span class="nx">fnMouseOut</span><span class="o">);</span>
        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">,</span> <span class="s2">&quot;mouseover&quot;</span><span class="o">,</span> <span class="nx">fnMouseOver</span><span class="o">);</span>
        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">,</span> <span class="s2">&quot;mouseout&quot;</span><span class="o">,</span> <span class="nx">fnMouseOut</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">);</span>
    
        <span class="k">this</span><span class="o">.</span><span class="nx">header</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">footer</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method configClassName</span>
<span class="c">* @description Event handler for when the &quot;classname&quot; configuration property of </span>
<span class="c">* a menu changes.</span>
<span class="c">* @param {String} p_sType The name of the event that was fired.</span>
<span class="c">* @param {Array} p_aArgs Collection of arguments sent when the event was fired.</span>
<span class="c">* @param {YAHOO.widget.Menu} p_oMenu The Menu instance fired the event.</span>
<span class="c">*/</span>
<span class="nx">configClassName</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sClassName</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sClassName</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sClassName</span><span class="o">);</span>

    <span class="o">}</span>

    <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">sClassName</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_sClassName</span> <span class="o">=</span> <span class="nx">sClassName</span><span class="o">;</span>

<span class="o">},</span>



<span class="c">// Public methods</span>
<span class="c"></span>


<span class="c">/**</span>
<span class="c">* @method initEvents</span>
<span class="c">* @description Initializes the custom events for the menu.</span>
<span class="c">*/</span>
<span class="nx">initEvents</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

	<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">initEvents</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>

    <span class="c">// Create custom events</span>
<span class="c"></span>
    <span class="k">var</span> <span class="nx">EVENT_TYPES</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">_EVENT_TYPES</span><span class="o">;</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">mouseOverEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">MOUSE_OVER</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">mouseOutEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">MOUSE_OUT</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">mouseDownEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">MOUSE_DOWN</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">mouseUpEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">MOUSE_UP</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">clickEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">CLICK</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">keyPressEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">KEY_PRESS</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">keyDownEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">KEY_DOWN</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">keyUpEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">KEY_UP</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">focusEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">FOCUS</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">blurEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">BLUR</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">itemAddedEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">ITEM_ADDED</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">itemRemovedEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">ITEM_REMOVED</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method getRoot</span>
<span class="c">* @description Finds the menu&#39;s root menu.</span>
<span class="c">*/</span>
<span class="nx">getRoot</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">parent</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oParentMenu</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">parent</span><span class="o">;</span>

        <span class="k">return</span> <span class="nx">oParentMenu</span> <span class="o">?</span> <span class="nx">oParentMenu</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">()</span> <span class="o">:</span> <span class="k">this</span><span class="o">;</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
    
        <span class="k">return</span> <span class="k">this</span><span class="o">;</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method toString</span>
<span class="c">* @description Returns a string representing the menu.</span>
<span class="c">* @return {String}</span>
<span class="c">*/</span>
<span class="nx">toString</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sReturnVal</span> <span class="o">=</span> <span class="s2">&quot;Menu&quot;</span><span class="o">,</span>
        <span class="nx">sId</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">sId</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">sReturnVal</span> <span class="o">+=</span> <span class="o">(</span><span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nx">sId</span><span class="o">);</span>
    
    <span class="o">}</span>

    <span class="k">return</span> <span class="nx">sReturnVal</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method setItemGroupTitle</span>
<span class="c">* @description Sets the title of a group of menu items.</span>
<span class="c">* @param {String} p_sGroupTitle String specifying the title of the group.</span>
<span class="c">* @param {Number} p_nGroupIndex Optional. Number specifying the group to which</span>
<span class="c">* the title belongs.</span>
<span class="c">*/</span>
<span class="nx">setItemGroupTitle</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sGroupTitle</span><span class="o">,</span> <span class="nx">p_nGroupIndex</span><span class="o">)</span> <span class="o">{</span>
        
    <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_sGroupTitle</span> <span class="o">==</span> <span class="s2">&quot;string&quot;</span> <span class="o">&amp;&amp;</span> <span class="nx">p_sGroupTitle</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">nGroupIndex</span> <span class="o">=</span> <span class="k">typeof</span> <span class="nx">p_nGroupIndex</span> <span class="o">==</span> <span class="s2">&quot;number&quot;</span> <span class="o">?</span> <span class="nx">p_nGroupIndex</span> <span class="o">:</span> <span class="m">0</span><span class="o">,</span>
            <span class="nx">oTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span><span class="o">[</span><span class="nx">nGroupIndex</span><span class="o">];</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">oTitle</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oTitle</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">p_sGroupTitle</span><span class="o">;</span>
            
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="nx">oTitle</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">GROUP_TITLE_TAG_NAME</span><span class="o">);</span>
                    
            <span class="nx">oTitle</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">p_sGroupTitle</span><span class="o">;</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span><span class="o">[</span><span class="nx">nGroupIndex</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oTitle</span><span class="o">;</span>

        <span class="o">}</span>


        <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span><span class="o">.</span><span class="nx">length</span> <span class="o">-</span> <span class="m">1</span><span class="o">,</span>
            <span class="nx">nFirstIndex</span><span class="o">;</span>

        <span class="k">do</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">{</span>

                <span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="s2">&quot;first-of-type&quot;</span><span class="o">);</span>

                <span class="nx">nFirstIndex</span> <span class="o">=</span> <span class="nx">i</span><span class="o">;</span>

            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">nFirstIndex</span> <span class="o">!==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span><span class="o">[</span><span class="nx">nFirstIndex</span><span class="o">],</span> 
                <span class="s2">&quot;first-of-type&quot;</span>
            <span class="o">);</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>



<span class="c">/**</span>
<span class="c">* @method addItem</span>
<span class="c">* @description Appends an item to the menu.</span>
<span class="c">* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem </span>
<span class="c">* instance to be added to the menu.</span>
<span class="c">* @param {String} p_oItem String specifying the text of the item to be added </span>
<span class="c">* to the menu.</span>
<span class="c">* @param {Object} p_oItem Object literal containing a set of menu item </span>
<span class="c">* configuration properties.</span>
<span class="c">* @param {Number} p_nGroupIndex Optional. Number indicating the group to</span>
<span class="c">* which the item belongs.</span>
<span class="c">* @return {YAHOO.widget.MenuItem}</span>
<span class="c">*/</span>
<span class="nx">addItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">,</span> <span class="nx">p_nGroupIndex</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_addItemToGroup</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">);</span>
        
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method addItems</span>
<span class="c">* @description Adds an array of items to the menu.</span>
<span class="c">* @param {Array} p_aItems Array of items to be added to the menu.  The array </span>
<span class="c">* can contain strings specifying the text for each item to be created, object</span>
<span class="c">* literals specifying each of the menu item configuration properties, </span>
<span class="c">* or MenuItem instances.</span>
<span class="c">* @param {Number} p_nGroupIndex Optional. Number specifying the group to </span>
<span class="c">* which the items belongs.</span>
<span class="c">* @return {Array}</span>
<span class="c">*/</span>
<span class="nx">addItems</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_aItems</span><span class="o">,</span> <span class="nx">p_nGroupIndex</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">p_aItems</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">nItems</span> <span class="o">=</span> <span class="nx">p_aItems</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
            <span class="nx">aItems</span> <span class="o">=</span> <span class="o">[],</span>
            <span class="nx">oItem</span><span class="o">;</span>


        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nItems</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>

            <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aItems</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">if</span><span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">oItem</span><span class="o">))</span> <span class="o">{</span>
    
                    <span class="nx">aItems</span><span class="o">[</span><span class="nx">aItems</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">addItems</span><span class="o">(</span><span class="nx">oItem</span><span class="o">,</span> <span class="nx">i</span><span class="o">);</span>
    
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
    
                    <span class="nx">aItems</span><span class="o">[</span><span class="nx">aItems</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">_addItemToGroup</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">,</span> <span class="nx">oItem</span><span class="o">);</span>
                
                <span class="o">}</span>

            <span class="o">}</span>
    
        <span class="o">}</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">aItems</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">return</span> <span class="nx">aItems</span><span class="o">;</span>
        
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method insertItem</span>
<span class="c">* @description Inserts an item into the menu at the specified index.</span>
<span class="c">* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem </span>
<span class="c">* instance to be added to the menu.</span>
<span class="c">* @param {String} p_oItem String specifying the text of the item to be added </span>
<span class="c">* to the menu.</span>
<span class="c">* @param {Object} p_oItem Object literal containing a set of menu item </span>
<span class="c">* configuration properties.</span>
<span class="c">* @param {Number} p_nItemIndex Number indicating the ordinal position at which</span>
<span class="c">* the item should be added.</span>
<span class="c">* @param {Number} p_nGroupIndex Optional. Number indicating the group to which </span>
<span class="c">* the item belongs.</span>
<span class="c">* @return {YAHOO.widget.MenuItem}</span>
<span class="c">*/</span>
<span class="nx">insertItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">,</span> <span class="nx">p_nItemIndex</span><span class="o">,</span> <span class="nx">p_nGroupIndex</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_addItemToGroup</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">,</span> <span class="nx">p_nItemIndex</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method removeItem</span>
<span class="c">* @description Removes the specified item from the menu.</span>
<span class="c">* @param {YAHOO.widget.MenuItem} p_oObject Object reference for the MenuItem </span>
<span class="c">* instance to be removed from the menu.</span>
<span class="c">* @param {Number} p_oObject Number specifying the index of the item </span>
<span class="c">* to be removed.</span>
<span class="c">* @param {Number} p_nGroupIndex Optional. Number specifying the group to </span>
<span class="c">* which the item belongs.</span>
<span class="c">* @return {YAHOO.widget.MenuItem}</span>
<span class="c">*/</span>
<span class="nx">removeItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oObject</span><span class="o">,</span> <span class="nx">p_nGroupIndex</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_oObject</span> <span class="o">!=</span> <span class="s2">&quot;undefined&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oItem</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">p_oObject</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuItem</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_removeItemFromGroupByValue</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">,</span> <span class="nx">p_oObject</span><span class="o">);</span>           

        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_oObject</span> <span class="o">==</span> <span class="s2">&quot;number&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_removeItemFromGroupByIndex</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">,</span> <span class="nx">p_oObject</span><span class="o">);</span>

        <span class="o">}</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oItem</span><span class="o">.</span><span class="nx">destroy</span><span class="o">();</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Item removed.&quot;</span> <span class="o">+</span> 
                <span class="s2">&quot; Text: &quot;</span> <span class="o">+</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;text&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> 
                <span class="s2">&quot; Index: &quot;</span> <span class="o">+</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">index</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> 
                <span class="s2">&quot; Group Index: &quot;</span> <span class="o">+</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">groupIndex</span><span class="o">);</span>

            <span class="k">return</span> <span class="nx">oItem</span><span class="o">;</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method getItems</span>
<span class="c">* @description Returns an array of all of the items in the menu.</span>
<span class="c">* @return {Array}</span>
<span class="c">*/</span>
<span class="nx">getItems</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">aGroups</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span><span class="o">,</span>
        <span class="nx">nGroups</span> <span class="o">=</span> <span class="nx">aGroups</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>

    <span class="k">return</span> <span class="o">(</span>
                <span class="o">(</span><span class="nx">nGroups</span> <span class="o">==</span> <span class="m">1</span><span class="o">)</span> <span class="o">?</span> <span class="nx">aGroups</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">:</span> 
                    <span class="o">(</span><span class="nb">Array</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">concat</span><span class="o">.</span><span class="nx">apply</span><span class="o">([],</span> <span class="nx">aGroups</span><span class="o">))</span>
            <span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method getItemGroups</span>
<span class="c">* @description Multi-dimensional Array representing the menu items as they </span>
<span class="c">* are grouped in the menu.</span>
<span class="c">* @return {Array}</span>
<span class="c">*/</span>        
<span class="nx">getItemGroups</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method getItem</span>
<span class="c">* @description Returns the item at the specified index.</span>
<span class="c">* @param {Number} p_nItemIndex Number indicating the ordinal position of the </span>
<span class="c">* item to be retrieved.</span>
<span class="c">* @param {Number} p_nGroupIndex Optional. Number indicating the group to which </span>
<span class="c">* the item belongs.</span>
<span class="c">* @return {YAHOO.widget.MenuItem}</span>
<span class="c">*/</span>
<span class="nx">getItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nItemIndex</span><span class="o">,</span> <span class="nx">p_nGroupIndex</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">p_nItemIndex</span> <span class="o">==</span> <span class="s2">&quot;number&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">aGroup</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItemGroup</span><span class="o">(</span><span class="nx">p_nGroupIndex</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">aGroup</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">return</span> <span class="nx">aGroup</span><span class="o">[</span><span class="nx">p_nItemIndex</span><span class="o">];</span>
        
        <span class="o">}</span>

    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method clearContent</span>
<span class="c">* @description Removes all of the content from the menu, including the menu </span>
<span class="c">* items, group titles, header and footer.</span>
<span class="c">*/</span>
<span class="nx">clearContent</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">aItems</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getItems</span><span class="o">(),</span>
        <span class="nx">nItems</span> <span class="o">=</span> <span class="nx">aItems</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
        <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span>
        <span class="nx">oBody</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">,</span>
        <span class="nx">oHeader</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">header</span><span class="o">,</span>
        <span class="nx">oFooter</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">footer</span><span class="o">;</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">nItems</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">nItems</span> <span class="o">-</span> <span class="m">1</span><span class="o">,</span>
            <span class="nx">oItem</span><span class="o">,</span>
            <span class="nx">oSubmenu</span><span class="o">;</span>

        <span class="k">do</span> <span class="o">{</span>

            <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">aItems</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>

                <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">configChangedEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">_onParentMenuConfigChange</span><span class="o">,</span> 
                                <span class="nx">oSubmenu</span>
                            <span class="o">);</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">renderEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span>
                                        <span class="k">this</span><span class="o">.</span><span class="nx">_onParentMenuRender</span><span class="o">,</span> 
                                        <span class="nx">oSubmenu</span>
                                    <span class="o">);</span>

                <span class="o">}</span>

                <span class="nx">oItem</span><span class="o">.</span><span class="nx">destroy</span><span class="o">();</span>

            <span class="o">}</span>
        
        <span class="o">}</span>
        <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">);</span>
        <span class="nx">oElement</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oHeader</span><span class="o">);</span>

    <span class="o">}</span>
    

    <span class="k">if</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">);</span>
        <span class="nx">oElement</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">);</span>
    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oBody</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">oBody</span><span class="o">);</span>

        <span class="nx">oBody</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>

    <span class="o">}</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span> <span class="o">=</span> <span class="o">[];</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span> <span class="o">=</span> <span class="o">[];</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span> <span class="o">=</span> <span class="o">[];</span>
    
    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;width&quot;</span><span class="o">,</span> <span class="kc">null</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method destroy</span>
<span class="c">* @description Removes the menu&#39;s &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element </span>
<span class="c">* (and accompanying child nodes) from the document.</span>
<span class="c">*/</span>
<span class="nx">destroy</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="c">// Remove all DOM event listeners</span>
<span class="c"></span>
    <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">);</span>


    <span class="c">// Remove Custom Event listeners</span>
<span class="c"></span>
    <span class="k">this</span><span class="o">.</span><span class="nx">mouseOverEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">mouseOutEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">mouseDownEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">mouseUpEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">clickEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">keyPressEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">keyDownEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">keyUpEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">focusEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">blurEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">itemAddedEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">itemRemovedEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">unsubscribeFromConfigEvent</span><span class="o">(</span><span class="s2">&quot;width&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onWidthChange</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">unsubscribeFromConfigEvent</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onVisibleChange</span><span class="o">);</span>

    <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_hasSetWidthHandlers</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">itemAddedEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setWidth</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">itemRemovedEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setWidth</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_hasSetWidthHandlers</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="o">}</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Module</span><span class="o">.</span><span class="nx">textResizeEvent</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onTextResize</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>


    <span class="c">// Remove all items</span>
<span class="c"></span>
    <span class="k">this</span><span class="o">.</span><span class="nx">clearContent</span><span class="o">();</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">_aItemGroups</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_aListElements</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_aGroupTitleElements</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>


    <span class="c">// Continue with the superclass implementation of this method</span>
<span class="c"></span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">destroy</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
    
    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Destroyed.&quot;</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method setInitialFocus</span>
<span class="c">* @description Sets focus to the menu&#39;s first enabled item.</span>
<span class="c">*/</span>
<span class="nx">setInitialFocus</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getFirstEnabledItem</span><span class="o">();</span>
    
    <span class="k">if</span> <span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">oItem</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>

    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method setInitialSelection</span>
<span class="c">* @description Sets the &quot;selected&quot; configuration property of the menu&#39;s first </span>
<span class="c">* enabled item to &quot;true.&quot;</span>
<span class="c">*/</span>
<span class="nx">setInitialSelection</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getFirstEnabledItem</span><span class="o">();</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    <span class="o">}</span>        

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method clearActiveItem</span>
<span class="c">* @description Sets the &quot;selected&quot; configuration property of the menu&#39;s active</span>
<span class="c">* item to &quot;false&quot; and hides the item&#39;s submenu.</span>
<span class="c">* @param {Boolean} p_bBlur Boolean indicating if the menu&#39;s active item </span>
<span class="c">* should be blurred.  </span>
<span class="c">*/</span>
<span class="nx">clearActiveItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_bBlur</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;showdelay&quot;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">this</span><span class="o">.</span><span class="nx">_cancelShowDelay</span><span class="o">();</span>
    
    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">oActiveItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oActiveItem</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oConfig</span> <span class="o">=</span> <span class="nx">oActiveItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">p_bBlur</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oActiveItem</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>
        
        <span class="o">}</span>

        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;selected&quot;</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>

        <span class="k">var</span> <span class="nx">oSubmenu</span> <span class="o">=</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;submenu&quot;</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oSubmenu</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oSubmenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>

        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">activeItem</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>            

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method focus</span>
<span class="c">* @description Causes the menu to receive focus and fires the &quot;focus&quot; event.</span>
<span class="c">*/</span>
<span class="nx">focus</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">hasFocus</span><span class="o">())</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">setInitialFocus</span><span class="o">();</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method blur</span>
<span class="c">* @description Causes the menu to lose focus and fires the &quot;blur&quot; event.</span>
<span class="c">*/</span>    
<span class="nx">blur</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasFocus</span><span class="o">())</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuManager</span><span class="o">.</span><span class="nx">getFocusedMenuItem</span><span class="o">();</span>
        
        <span class="k">if</span> <span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oItem</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method hasFocus</span>
<span class="c">* @description Returns a boolean indicating whether or not the menu has focus.</span>
<span class="c">* @return {Boolean}</span>
<span class="c">*/</span>
<span class="nx">hasFocus</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">return</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuManager</span><span class="o">.</span><span class="nx">getFocusedMenu</span><span class="o">()</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRoot</span><span class="o">());</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @description Initializes the class&#39;s configurable properties which can be</span>
<span class="c">* changed using the menu&#39;s Config object (&quot;cfg&quot;).</span>
<span class="c">* @method initDefaultConfig</span>
<span class="c">*/</span>
<span class="nx">initDefaultConfig</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">initDefaultConfig</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>

    <span class="k">var</span> <span class="nx">oConfig</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">,</span>
        <span class="nx">DEFAULT_CONFIG</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">.</span><span class="nx">_DEFAULT_CONFIG</span><span class="o">;</span>

	<span class="c">// Add configuration attributes</span>
<span class="c"></span>
    <span class="c">/*</span>
<span class="c">        Change the default value for the &quot;visible&quot; configuration </span>
<span class="c">        property to &quot;false&quot; by re-adding the property.</span>
<span class="c">    */</span>

    <span class="c">/**</span>
<span class="c">    * @config visible</span>
<span class="c">    * @description Boolean indicating whether or not the menu is visible.  If </span>
<span class="c">    * the menu&#39;s &quot;position&quot; configuration property is set to &quot;dynamic&quot; (the </span>
<span class="c">    * default), this property toggles the menu&#39;s &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; </span>
<span class="c">    * element&#39;s &quot;visibility&quot; style property between &quot;visible&quot; (true) or </span>
<span class="c">    * &quot;hidden&quot; (false).  If the menu&#39;s &quot;position&quot; configuration property is </span>
<span class="c">    * set to &quot;static&quot; this property toggles the menu&#39;s </span>
<span class="c">    * &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element&#39;s &quot;display&quot; style property </span>
<span class="c">    * between &quot;block&quot; (true) or &quot;none&quot; (false).</span>
<span class="c">    * @default false</span>
<span class="c">    * @type Boolean</span>
<span class="c">    */</span>
    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
        <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">VISIBLE</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
        <span class="o">{</span>
            <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configVisible</span><span class="o">,</span> 
            <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">VISIBLE</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
            <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">VISIBLE</span><span class="o">.</span><span class="nx">validator</span>
         <span class="o">}</span>
     <span class="o">);</span>


    <span class="c">/*</span>
<span class="c">        Change the default value for the &quot;constraintoviewport&quot; configuration </span>
<span class="c">        property to &quot;true&quot; by re-adding the property.</span>
<span class="c">    */</span>

    <span class="c">/**</span>
<span class="c">    * @config constraintoviewport</span>
<span class="c">    * @description Boolean indicating if the menu will try to remain inside </span>
<span class="c">    * the boundaries of the size of viewport.</span>
<span class="c">    * @default true</span>
<span class="c">    * @type Boolean</span>
<span class="c">    */</span>
    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
        <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CONSTRAIN_TO_VIEWPORT</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
        <span class="o">{</span>
            <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configConstrainToViewport</span><span class="o">,</span> 
            <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CONSTRAIN_TO_VIEWPORT</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
            <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CONSTRAIN_TO_VIEWPORT</span><span class="o">.</span><span class="nx">validator</span><span class="o">,</span> 
            <span class="nx">supercedes</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CONSTRAIN_TO_VIEWPORT</span><span class="o">.</span><span class="nx">supercedes</span> 
        <span class="o">}</span> 
    <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config position</span>
<span class="c">    * @description String indicating how a menu should be positioned on the </span>
<span class="c">    * screen.  Possible values are &quot;static&quot; and &quot;dynamic.&quot;  Static menus are </span>
<span class="c">    * visible by default and reside in the normal flow of the document </span>
<span class="c">    * (CSS position: static).  Dynamic menus are hidden by default, reside </span>
<span class="c">    * out of the normal flow of the document (CSS position: absolute), and </span>
<span class="c">    * can overlay other elements on the screen.</span>
<span class="c">    * @default dynamic</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
        <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">POSITION</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
        <span class="o">{</span>
            <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configPosition</span><span class="o">,</span>
            <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">POSITION</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
            <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">POSITION</span><span class="o">.</span><span class="nx">validator</span><span class="o">,</span>
            <span class="nx">supercedes</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">POSITION</span><span class="o">.</span><span class="nx">supercedes</span>
        <span class="o">}</span>
    <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config submenualignment</span>
<span class="c">    * @description Array defining how submenus should be aligned to their </span>
<span class="c">    * parent menu item. The format is: [itemCorner, submenuCorner]. By default</span>
<span class="c">    * a submenu&#39;s top left corner is aligned to its parent menu item&#39;s top </span>
<span class="c">    * right corner.</span>
<span class="c">    * @default [&quot;tl&quot;,&quot;tr&quot;]</span>
<span class="c">    * @type Array</span>
<span class="c">    */</span>
    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
        <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">SUBMENU_ALIGNMENT</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
        <span class="o">{</span> 
            <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">SUBMENU_ALIGNMENT</span><span class="o">.</span><span class="nx">value</span> 
        <span class="o">}</span>
    <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config autosubmenudisplay</span>
<span class="c">    * @description Boolean indicating if submenus are automatically made </span>
<span class="c">    * visible when the user mouses over the menu&#39;s items.</span>
<span class="c">    * @default true</span>
<span class="c">    * @type Boolean</span>
<span class="c">    */</span>
	<span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
	   <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">AUTO_SUBMENU_DISPLAY</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
	   <span class="o">{</span> 
	       <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">AUTO_SUBMENU_DISPLAY</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
	       <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">AUTO_SUBMENU_DISPLAY</span><span class="o">.</span><span class="nx">validator</span>
       <span class="o">}</span> 
    <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config showdelay</span>
<span class="c">    * @description Number indicating the time (in milliseconds) that should </span>
<span class="c">    * expire before a submenu is made visible when the user mouses over </span>
<span class="c">    * the menu&#39;s items.</span>
<span class="c">    * @default 250</span>
<span class="c">    * @type Number</span>
<span class="c">    */</span>
	<span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
	   <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">SHOW_DELAY</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
	   <span class="o">{</span> 
	       <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">SHOW_DELAY</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
	       <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">SHOW_DELAY</span><span class="o">.</span><span class="nx">validator</span>
       <span class="o">}</span> 
    <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config hidedelay</span>
<span class="c">    * @description Number indicating the time (in milliseconds) that should </span>
<span class="c">    * expire before the menu is hidden.</span>
<span class="c">    * @default 0</span>
<span class="c">    * @type Number</span>
<span class="c">    */</span>
	<span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
	   <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">HIDE_DELAY</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
	   <span class="o">{</span> 
	       <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configHideDelay</span><span class="o">,</span>
	       <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">HIDE_DELAY</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
	       <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">HIDE_DELAY</span><span class="o">.</span><span class="nx">validator</span><span class="o">,</span> 
	       <span class="nx">suppressEvent</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">HIDE_DELAY</span><span class="o">.</span><span class="nx">suppressEvent</span>
       <span class="o">}</span> 
    <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config submenuhidedelay</span>
<span class="c">    * @description Number indicating the time (in milliseconds) that should </span>
<span class="c">    * expire before a submenu is hidden when the user mouses out of a menu item </span>
<span class="c">    * heading in the direction of a submenu.  The value must be greater than or </span>
<span class="c">    * equal to the value specified for the &quot;showdelay&quot; configuration property.</span>
<span class="c">    * @default 250</span>
<span class="c">    * @type Number</span>
<span class="c">    */</span>
	<span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
	   <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">SUBMENU_HIDE_DELAY</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
	   <span class="o">{</span> 
	       <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">SUBMENU_HIDE_DELAY</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
	       <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">SUBMENU_HIDE_DELAY</span><span class="o">.</span><span class="nx">validator</span>
       <span class="o">}</span> 
    <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config clicktohide</span>
<span class="c">    * @description Boolean indicating if the menu will automatically be </span>
<span class="c">    * hidden if the user clicks outside of it.</span>
<span class="c">    * @default true</span>
<span class="c">    * @type Boolean</span>
<span class="c">    */</span>
    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
        <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CLICK_TO_HIDE</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span>
        <span class="o">{</span>
            <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CLICK_TO_HIDE</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span>
            <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CLICK_TO_HIDE</span><span class="o">.</span><span class="nx">validator</span>
        <span class="o">}</span>
    <span class="o">);</span>


	<span class="c">/**</span>
<span class="c">	* @config container</span>
<span class="c">	* @description HTML element reference or string specifying the id </span>
<span class="c">	* attribute of the HTML element that the menu&#39;s markup should be </span>
<span class="c">	* rendered into.</span>
<span class="c">	* @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">	* level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;|String</span>
<span class="c">	* @default document.body</span>
<span class="c">	*/</span>
	<span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
	   <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CONTAINER</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
	   <span class="o">{</span> 
	       <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configContainer</span><span class="o">,</span>
	       <span class="nx">value</span><span class="o">:</span> <span class="nb">document</span><span class="o">.</span><span class="nx">body</span>
       <span class="o">}</span> 
   <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config maxheight</span>
<span class="c">    * @description Defines the maximum height (in pixels) for a menu before the</span>
<span class="c">    * contents of the body are scrolled.</span>
<span class="c">    * @default 0</span>
<span class="c">    * @type Number</span>
<span class="c">    */</span>
    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
       <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">MAX_HEIGHT</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
       <span class="o">{</span>
            <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configMaxHeight</span><span class="o">,</span>
            <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">MAX_HEIGHT</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span>
            <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">MAX_HEIGHT</span><span class="o">.</span><span class="nx">validator</span>
       <span class="o">}</span> 
    <span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config classname</span>
<span class="c">    * @description CSS class to be applied to the menu&#39;s root </span>
<span class="c">    * &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element.  The specified class(es) are </span>
<span class="c">    * appended in addition to the default class as specified by the menu&#39;s</span>
<span class="c">    * CSS_CLASS_NAME constant.</span>
<span class="c">    * @default null</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
        <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CLASS_NAME</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
        <span class="o">{</span> 
            <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configClassName</span><span class="o">,</span>
            <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CLASS_NAME</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
            <span class="nx">validator</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">CLASS_NAME</span><span class="o">.</span><span class="nx">validator</span>
        <span class="o">}</span>
    <span class="o">);</span>

<span class="o">}</span>

<span class="o">});</span> <span class="c">// END YAHOO.lang.extend</span>
<span class="c"></span>
<span class="o">})();</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class=""><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class=""><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class=""><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class="selected"><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.widget.ContextMenu.html">YAHOO.widget.ContextMenu</a></li>
                                <li class=""><a href="YAHOO.widget.ContextMenuItem.html">YAHOO.widget.ContextMenuItem</a></li>
                                <li class=""><a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a></li>
                                <li class=""><a href="YAHOO.widget.Menubar.html">YAHOO.widget.Menubar</a></li>
                                <li class=""><a href="YAHOO.widget.MenuBarItem.html">YAHOO.widget.MenuBarItem</a></li>
                                <li class=""><a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a></li>
                                <li class=""><a href="YAHOO.widget.MenuManager.html">YAHOO.widget.MenuManager</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="contextmenu.js.html">contextmenu.js</a></li>
                                <li class=""><a href="contextmenuitem.js.html">contextmenuitem.js</a></li>
                                <li class="selected"><a href="menu.js.html">menu.js</a></li>
                                <li class=""><a href="menubar.js.html">menubar.js</a></li>
                                <li class=""><a href="menubaritem.js.html">menubaritem.js</a></li>
                                <li class=""><a href="menuitem.js.html">menuitem.js</a></li>
                                <li class=""><a href="menumanager.js.html">menumanager.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
